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;
};