forked from Choices-js/Choices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.prod.js
56 lines (53 loc) · 1.38 KB
/
webpack.config.prod.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var path = require('path');
var package = require('./package.json');
var webpack = require('webpack');
var wrapperPlugin = require('wrapper-webpack-plugin');
var banner = `/*! ${ package.name } v${ package.version } | (c) ${ new Date().getFullYear() } ${ package.author } | ${ package.homepage } */ \n`;
var minimize = process.argv.indexOf('--minimize') !== -1;
var config = {
devtool: 'cheap-module-source-map',
entry: [
'./assets/scripts/src/choices'
],
output: {
path: path.join(__dirname, '/assets/scripts/dist'),
filename: minimize ? 'choices.min.js' : 'choices.js',
publicPath: '/assets/scripts/dist/',
library: 'Choices',
libraryTarget: 'umd',
},
libraryTarget: 'umd',
plugins: [
new webpack.DefinePlugin({
'process.env': {
// This has effect on the react lib size
'NODE_ENV': JSON.stringify('production'),
}
}),
new wrapperPlugin({
header: banner,
}),
],
module: {
loaders: [{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loaders: ['babel'],
include: path.join(__dirname, 'assets/scripts/src')
}]
}
};
if (minimize) {
config.plugins.unshift(new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
mangle: true,
output: {
comments: false
},
compress: {
warnings: false,
screw_ie8: true
}
}));
}
module.exports = config;