updeep-remeda/createWebpackConfig.js

60 lines
1.1 KiB
JavaScript
Raw Normal View History

'use strict'; /* eslint strict:0, no-var:0, func-names:0 */
var webpack = require('webpack');
2015-08-04 17:39:56 +00:00
module.exports = function createWebpackConfig(_options) {
var config;
var options = _options || {};
2015-08-22 18:03:38 +00:00
var env = options.env || 'development';
2015-08-04 17:39:56 +00:00
config = {
2015-08-10 06:25:19 +00:00
context: options.context,
entry: options.entry,
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
2015-08-22 18:03:38 +00:00
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(env),
},
}),
],
2015-08-22 18:03:38 +00:00
node: {
process: false,
},
module: {
loaders: [
{ test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/ },
],
},
output: {
library: 'updeep',
libraryTarget: 'umd',
},
resolve: {
extensions: ['', '.js'],
},
};
config.output.filename = options.filename;
if (options.minify) {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compressor: {
2015-08-22 18:03:38 +00:00
pure_getters: true,
unsafe: true,
unsafe_comps: true,
screw_ie8: true,
warnings: false,
},
})
);
}
return config;
};