Skip to content

Commit

Permalink
Create UMD bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
ahocevar committed Feb 5, 2020
1 parent 0277bcd commit 28e3dd9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 32 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"test": "npm run karma -- --single-run --log-level error"
},
"dependencies": {
"@mapbox/mapbox-gl-style-spec": "^13.10.1",
"@mapbox/mapbox-gl-style-spec": "^13.11.0",
"mapbox-to-css-font": "^2.4.0",
"webfont-matcher": "^1.1.0"
},
Expand Down
12 changes: 3 additions & 9 deletions src/olms.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import olms, {apply, applyBackground, applyStyle} from './index';
import stylefunction from './stylefunction';
export {default as olms} from './index';
export {apply, applyBackground, applyStyle} from './index';
export {default as stylefunction} from './stylefunction';

const exports = /** @type {Object} */ (olms);
exports.apply = apply;
exports.applyBackground = applyBackground;
exports.applyStyle = applyStyle;
exports.stylefunction = stylefunction;

export default exports;
59 changes: 37 additions & 22 deletions webpack.config.olms.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
const path = require('path');

const externals = {
'ol/style/Style': 'ol.style.Style',
'ol/style/Circle': 'ol.style.Circle',
'ol/style/Icon': 'ol.style.Icon',
'ol/style/Stroke': 'ol.style.Stroke',
'ol/style/Fill': 'ol.style.Fill',
'ol/proj': 'ol.proj',
'ol/tilegrid': 'ol.tilegrid',
'ol/tilegrid/TileGrid': 'ol.tilegrid.TileGrid',
'ol/format/GeoJSON': 'ol.format.GeoJSON',
'ol/format/MVT': 'ol.format.MVT',
'ol/Map': 'ol.Map',
'ol/View': 'ol.View',
'ol/Observable': 'ol.Observable',
'ol/layer/Tile': 'ol.layer.Tile',
'ol/layer/Vector': 'ol.layer.Vector',
'ol/layer/VectorTile': 'ol.layer.VectorTile',
'ol/source/TileJSON': 'ol.source.TileJSON',
'ol/source/Vector': 'ol.source.Vector',
'ol/source/VectorTile': 'ol.source.VectorTile'
};

function createExternals() {
const createdExternals = {};
for (const key in externals) {
createdExternals[key] = {
root: externals[key].split('.'),
commonjs: key,
commonjs2: key,
amd: key
};
}
return createdExternals;
}

module.exports = {
entry: './src/olms.js',
devtool: 'source-map',
Expand All @@ -22,28 +57,8 @@ module.exports = {
path: path.resolve('./dist'), // Path of output file
filename: 'olms.js',
library: 'olms',
libraryTarget: 'assign',
libraryTarget: 'umd',
libraryExport: 'default'
},
externals: {
'ol/style/Style': 'ol.style.Style',
'ol/style/Circle': 'ol.style.Circle',
'ol/style/Icon': 'ol.style.Icon',
'ol/style/Stroke': 'ol.style.Stroke',
'ol/style/Fill': 'ol.style.Fill',
'ol/proj': 'ol.proj',
'ol/tilegrid': 'ol.tilegrid',
'ol/tilegrid/TileGrid': 'ol.tilegrid.TileGrid',
'ol/format/GeoJSON': 'ol.format.GeoJSON',
'ol/format/MVT': 'ol.format.MVT',
'ol/Map': 'ol.Map',
'ol/View': 'ol.View',
'ol/Observable': 'ol.Observable',
'ol/layer/Tile': 'ol.layer.Tile',
'ol/layer/Vector': 'ol.layer.Vector',
'ol/layer/VectorTile': 'ol.layer.VectorTile',
'ol/source/TileJSON': 'ol.source.TileJSON',
'ol/source/Vector': 'ol.source.Vector',
'ol/source/VectorTile': 'ol.source.VectorTile'
}
externals: createExternals()
};

0 comments on commit 28e3dd9

Please sign in to comment.