Choices/webpack.config.prod.js

57 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2016-03-15 23:42:10 +01:00
var path = require('path');
2017-07-13 10:04:55 +02:00
var pkg = require('./package.json');
2016-03-15 23:42:10 +01:00
var webpack = require('webpack');
2016-08-12 16:51:31 +02:00
var wrapperPlugin = require('wrapper-webpack-plugin');
2017-07-13 10:04:55 +02:00
var banner = `/*! ${ pkg.name } v${ pkg.version } | (c) ${ new Date().getFullYear() } ${ pkg.author } | ${ pkg.homepage } */ \n`;
2016-08-23 08:24:45 +02:00
var minimize = process.argv.indexOf('--minimize') !== -1;
2016-03-15 23:42:10 +01:00
2016-08-23 08:24:45 +02:00
var config = {
2016-09-15 22:04:15 +02:00
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',
2016-10-18 15:15:00 +02:00
publicPath: '/assets/scripts/dist/',
library: 'Choices',
libraryTarget: 'umd',
2016-09-15 22:04:15 +02:00
},
2016-10-18 15:15:00 +02:00
libraryTarget: 'umd',
2016-09-15 22:04:15 +02:00
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')
}]
}
2016-08-23 08:24:45 +02:00
};
if (minimize) {
2016-09-15 22:04:15 +02:00
config.plugins.unshift(new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
mangle: true,
output: {
comments: false
},
compress: {
warnings: false,
screw_ie8: true
}
}));
2016-08-23 08:24:45 +02:00
}
2016-10-18 15:15:00 +02:00
module.exports = config;