Separate example scripts for dev and prod
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user