Skip to content

Commit

Permalink
Merge pull request #228 from jonataswalker/update-demo
Browse files Browse the repository at this point in the history
fix: add IIFE version & update fiddle
  • Loading branch information
jonataswalker authored Sep 22, 2022
2 parents ed222ec + d1281b1 commit a146954
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ A `contextmenu` extension for [OpenLayers](http://openlayers.org/). **Requires**

## Demo

You can see [here a demo](http://rawgit.com/jonataswalker/ol-contextmenu/master/examples/contextmenu.html) or [JSFiddle](https://jsfiddle.net/jonataswalker/ooxs1w5d/).
[JSFiddle](https://jsfiddle.net/jonataswalker/ooxs1w5d/).

## How to use it?

Expand Down
2 changes: 1 addition & 1 deletion examples/contextmenu.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<body>
<div id="map" tabindex="0"></div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ol.js"></script>
<script src="../dist/ol-contextmenu.umd.cjs"></script>
<script src="../dist/ol-contextmenu.iife.js"></script>
<script src="contextmenu.js"></script>
</body>
</html>
17 changes: 15 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "ol-contextmenu",
"version": "5.0.0",
"version": "5.0.3",
"description": "Custom Context Menu for Openlayers",
"type": "module",
"main": "./dist/ol-contextmenu.umd.cjs",
"browser": "./dist/ol-contextmenu.iife.js",
"module": "./dist/ol-contextmenu.js",
"exports": {
".": {
Expand Down Expand Up @@ -60,6 +61,7 @@
"rimraf": "^3.0.2",
"typescript": "^4.8.3",
"vite": "^3.1.3",
"vite-plugin-banner": "^0.5.0",
"vite-plugin-dts": "^1.5.0"
},
"peerDependencies": {
Expand Down
9 changes: 0 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,3 @@ export default class ContextMenu extends Control {
}
}
}

// Expose ContextMenu as ol.control.ContextMenu if using a full build of OpenLayers
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
if (window.ol?.control) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
window.ol.control.ContextMenu = ContextMenu;
}
17 changes: 15 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { readFileSync } from 'fs';

import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import bannerPlugin from 'vite-plugin-banner';

import { CSS_CLASSES } from './src/constants';

Expand All @@ -14,6 +15,14 @@ const globals = {
ol: 'ol',
};

const banner = `
/*!
* ${pkg.name} - v${pkg.version}
* ${pkg.homepage}
* Built: ${new Date()}
*/
`;

const additionalData = Object.keys(CSS_CLASSES).reduce(
(accumulator, current) => `${accumulator}$${current}:${CSS_CLASSES[String(current)]};`,
''
Expand All @@ -35,13 +44,17 @@ export default defineConfig(({ command }) =>
entry: './src/main.ts',
name: 'ContextMenu',
fileName: 'ol-contextmenu',
formats: ['es', 'umd', 'iife'],
},
rollupOptions: {
external,
output: { globals, assetFileNames: () => 'ol-contextmenu.css' },
output: {
globals,
assetFileNames: () => 'ol-contextmenu.css',
},
},
},
plugins: [dts({ insertTypesEntry: true })],
plugins: [dts({ insertTypesEntry: true }), bannerPlugin(banner)],
define: {
__APP_VERSION__: JSON.stringify(pkg.version),
},
Expand Down

0 comments on commit a146954

Please sign in to comment.