2018-11-27 17:32:22 +00:00
|
|
|
"use strict"; // eslint-disable-line
|
2017-04-19 00:47:53 +00:00
|
|
|
/* eslint no-var:0, func-names:0, import/no-extraneous-dependencies:0 */
|
|
|
|
|
2018-11-27 17:32:22 +00:00
|
|
|
var webpack = require('webpack')
|
2015-08-04 17:08:44 +00:00
|
|
|
|
2015-08-04 17:39:56 +00:00
|
|
|
module.exports = function createWebpackConfig(_options) {
|
2018-11-27 17:32:22 +00:00
|
|
|
var config
|
|
|
|
var options = _options || {}
|
|
|
|
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,
|
|
|
|
|
2015-08-04 17:08:44 +00:00
|
|
|
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-04 17:08:44 +00:00
|
|
|
],
|
|
|
|
|
2015-08-22 18:03:38 +00:00
|
|
|
node: {
|
|
|
|
process: false,
|
|
|
|
},
|
|
|
|
|
2015-08-04 17:08:44 +00:00
|
|
|
module: {
|
|
|
|
loaders: [
|
|
|
|
{ test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/ },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
output: {
|
|
|
|
library: 'updeep',
|
|
|
|
libraryTarget: 'umd',
|
|
|
|
},
|
|
|
|
|
|
|
|
resolve: {
|
|
|
|
extensions: ['', '.js'],
|
|
|
|
},
|
2018-11-27 17:32:22 +00:00
|
|
|
}
|
2015-08-04 17:08:44 +00:00
|
|
|
|
2018-11-27 17:32:22 +00:00
|
|
|
config.output.filename = options.filename
|
2015-08-04 17:08:44 +00:00
|
|
|
|
|
|
|
if (options.minify) {
|
2015-08-10 05:40:23 +00:00
|
|
|
config.plugins.push(
|
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
|
|
compressor: {
|
2015-08-22 18:03:38 +00:00
|
|
|
pure_getters: true,
|
|
|
|
unsafe: true,
|
|
|
|
unsafe_comps: true,
|
2015-08-10 05:40:23 +00:00
|
|
|
screw_ie8: true,
|
|
|
|
warnings: false,
|
|
|
|
},
|
|
|
|
})
|
2018-11-27 17:32:22 +00:00
|
|
|
)
|
2015-08-10 05:40:23 +00:00
|
|
|
}
|
|
|
|
|
2018-11-27 17:32:22 +00:00
|
|
|
return config
|
|
|
|
}
|