Separate example scripts for dev and prod

This commit is contained in:
Tim Schaub
2017-08-27 10:21:07 -06:00
committed by Tim Schaub
parent 93411a2b91
commit 8a9bbd6264
26 changed files with 71 additions and 28 deletions

View File

@@ -1,4 +1,4 @@
import _ol_ from '../src/ol.js';
import _ol_ from '../src/ol/index.js';
import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js';
import _ol_control_ from '../src/ol/control.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../src/ol.js';
import _ol_ from '../src/ol/index.js';
import _ol_Feature_ from '../src/ol/Feature.js';
import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js';

View File

@@ -1,6 +1,8 @@
const MinifyPlugin = require('babel-minify-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const ExampleBuilder = require('./example-builder');
const fs = require('fs');
const merge = require('webpack-merge');
const path = require('path');
const webpack = require('webpack');
@@ -15,7 +17,7 @@ examples.forEach(example => {
entry[example] = `./${example}.js`;
});
module.exports = {
const main = {
context: src,
target: 'web',
entry: entry,
@@ -36,8 +38,45 @@ module.exports = {
{from: 'index.html', to: 'index.html'}
])
],
devtool: 'source-map',
output: {
filename: '[name].js',
path: path.join(__dirname, '..', '..', 'build', 'examples')
}
};
// configuration specific to the dev environment
const dev = {
plugins: [
new webpack.EnvironmentPlugin(
Object.assign({NODE_ENV: 'development'}, process.env)
)
]
};
// configuration specific to the prod environment
const prod = {
plugins: [
new webpack.EnvironmentPlugin(
Object.assign({NODE_ENV: 'production'}, process.env)
),
new MinifyPlugin()
]
};
module.exports = env => {
let config;
switch (env) {
case 'prod': {
config = merge(main, prod);
break;
}
default: {
config = merge(main, dev);
}
}
return config;
};

View File

@@ -23,7 +23,8 @@
"transform-examples": "jscodeshift --transform transforms/module.js examples",
"transform-test": "jscodeshift --transform transforms/module.js test",
"transform": "npm run changecase-src && npm run transform-src && npm run transform-examples && npm run transform-test && npm run lint -- --fix",
"build-examples": "webpack --config examples/webpack/config.js"
"serve-examples": "mkdir -p build/examples && webpack --config examples/webpack/config.js --watch & serve build/examples",
"build-examples": "webpack --config examples/webpack/config.js --env=prod"
},
"main": "dist/ol.js",
"repository": {
@@ -55,11 +56,12 @@
"walk": "2.3.9"
},
"devDependencies": {
"babel-minify-webpack-plugin": "^0.2.0",
"clean-css-cli": "4.1.10",
"copy-webpack-plugin": "^4.0.1",
"coveralls": "3.0.0",
"debounce": "^1.1.0",
"eslint": "4.13.1",
"copy-webpack-plugin": "^4.0.1",
"eslint-config-openlayers": "7.0.0",
"eslint-plugin-openlayers-internal": "^3.1.0",
"expect.js": "0.3.1",
@@ -86,12 +88,14 @@
"phantomjs-prebuilt": "2.1.16",
"pixelmatch": "^4.0.2",
"proj4": "2.4.4",
"serve": "^6.0.6",
"serve-files": "1.0.1",
"sinon": "4.1.3",
"slimerjs": "0.10.3",
"url-polyfill": "^1.0.7",
"webpack": "^3.5.5",
"webpack-dev-server": "^2.7.1"
"webpack-dev-server": "^2.7.1",
"webpack-merge": "^4.1.0"
},
"eslintConfig": {
"extends": "openlayers",

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../src/ol.js';
import _ol_ from '../../../src/ol/index.js';
import _ol_AssertionError_ from '../../../src/ol/AssertionError.js';
describe('ol.AssertionError', function() {

View File

@@ -1,5 +1,5 @@
import _ol_color_ from '../../../src/ol/color.js';
import _ol_ from '../../../src/ol.js';
import _ol_ from '../../../src/ol/index.js';
describe('ol.color', function() {

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../src/ol.js';
import _ol_ from '../../../src/ol/index.js';
describe('getUid()', function() {
it('is constant once generated', function() {

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../src/ol.js';
import _ol_ from '../../../../src/ol/index.js';
import _ol_View_ from '../../../../src/ol/View.js';
import _ol_events_Event_ from '../../../../src/ol/events/Event.js';
import _ol_events_EventTarget_ from '../../../../src/ol/events/EventTarget.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../src/ol.js';
import _ol_ from '../../../../src/ol/index.js';
import _ol_array_ from '../../../../src/ol/array.js';
import _ol_Collection_ from '../../../../src/ol/Collection.js';
import _ol_extent_ from '../../../../src/ol/extent.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../src/ol.js';
import _ol_ from '../../../../src/ol/index.js';
import _ol_Map_ from '../../../../src/ol/Map.js';
import _ol_layer_Layer_ from '../../../../src/ol/layer/Layer.js';
import _ol_proj_ from '../../../../src/ol/proj.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../src/ol.js';
import _ol_ from '../../../src/ol/index.js';
import _ol_net_ from '../../../src/ol/net.js';
describe('ol.net', function() {

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../../src/ol.js';
import _ol_ from '../../../../../src/ol/index.js';
import _ol_Feature_ from '../../../../../src/ol/Feature.js';
import _ol_geom_Circle_ from '../../../../../src/ol/geom/Circle.js';
import _ol_render_webgl_CircleReplay_ from '../../../../../src/ol/render/webgl/CircleReplay.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../../src/ol.js';
import _ol_ from '../../../../../src/ol/index.js';
import _ol_Feature_ from '../../../../../src/ol/Feature.js';
import _ol_geom_LineString_ from '../../../../../src/ol/geom/LineString.js';
import _ol_geom_MultiLineString_ from '../../../../../src/ol/geom/MultiLineString.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../../src/ol.js';
import _ol_ from '../../../../../src/ol/index.js';
import _ol_Feature_ from '../../../../../src/ol/Feature.js';
import _ol_geom_MultiPolygon_ from '../../../../../src/ol/geom/MultiPolygon.js';
import _ol_geom_Polygon_ from '../../../../../src/ol/geom/Polygon.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../../src/ol.js';
import _ol_ from '../../../../../src/ol/index.js';
import _ol_Feature_ from '../../../../../src/ol/Feature.js';
import _ol_Map_ from '../../../../../src/ol/Map.js';
import _ol_View_ from '../../../../../src/ol/View.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../../src/ol.js';
import _ol_ from '../../../../../src/ol/index.js';
import _ol_Feature_ from '../../../../../src/ol/Feature.js';
import _ol_geom_GeometryCollection_ from '../../../../../src/ol/geom/GeometryCollection.js';
import _ol_geom_LineString_ from '../../../../../src/ol/geom/LineString.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../../src/ol.js';
import _ol_ from '../../../../../src/ol/index.js';
import _ol_Feature_ from '../../../../../src/ol/Feature.js';
import _ol_Map_ from '../../../../../src/ol/Map.js';
import _ol_View_ from '../../../../../src/ol/View.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../../src/ol.js';
import _ol_ from '../../../../../src/ol/index.js';
import _ol_obj_ from '../../../../../src/ol/obj.js';
import _ol_Feature_ from '../../../../../src/ol/Feature.js';
import _ol_Map_ from '../../../../../src/ol/Map.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../src/ol.js';
import _ol_ from '../../../../src/ol/index.js';
import _ol_events_ from '../../../../src/ol/events.js';
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../src/ol.js';
import _ol_ from '../../../../src/ol/index.js';
import _ol_Tile_ from '../../../../src/ol/Tile.js';
import _ol_TileRange_ from '../../../../src/ol/TileRange.js';
import _ol_proj_ from '../../../../src/ol/proj.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../src/ol.js';
import _ol_ from '../../../../src/ol/index.js';
import _ol_events_ from '../../../../src/ol/events.js';
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js';
import _ol_source_Zoomify_ from '../../../../src/ol/source/Zoomify.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../src/ol.js';
import _ol_ from '../../../../src/ol/index.js';
import _ol_style_ from '../../../../src/ol/style.js';
import _ol_style_Icon_ from '../../../../src/ol/style/Icon.js';
import _ol_style_IconImage_ from '../../../../src/ol/style/IconImage.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../src/ol.js';
import _ol_ from '../../../../src/ol/index.js';
import _ol_events_ from '../../../../src/ol/events.js';
import _ol_style_ from '../../../../src/ol/style.js';
import _ol_style_IconImage_ from '../../../../src/ol/style/IconImage.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../src/ol.js';
import _ol_ from '../../../src/ol/index.js';
import _ol_ImageTile_ from '../../../src/ol/ImageTile.js';
import _ol_Tile_ from '../../../src/ol/Tile.js';
import _ol_TileState_ from '../../../src/ol/TileState.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../../src/ol.js';
import _ol_ from '../../../../src/ol/index.js';
import _ol_TileRange_ from '../../../../src/ol/TileRange.js';
import _ol_extent_ from '../../../../src/ol/extent.js';
import _ol_proj_ from '../../../../src/ol/proj.js';

View File

@@ -1,4 +1,4 @@
import _ol_ from '../../../src/ol.js';
import _ol_ from '../../../src/ol/index.js';
import _ol_Map_ from '../../../src/ol/Map.js';
import _ol_View_ from '../../../src/ol/View.js';
import _ol_ViewHint_ from '../../../src/ol/ViewHint.js';