Choices/webpack.config.prod.js

57 lines
1.4 KiB
JavaScript
Raw Normal View History

const path = require('path');
const pkg = require('./package.json');
const webpack = require('webpack');
const wrapperPlugin = require('wrapper-webpack-plugin');
const banner = `/*! ${ pkg.name } v${ pkg.version } | (c) ${ new Date().getFullYear() } ${ pkg.author } | ${ pkg.homepage } */ \n`;
const minimize = process.argv.includes('--minimize');
2016-03-15 23:42:10 +01:00
const config = {
devtool: minimize ? false : 'cheap-module-source-map',
2016-09-15 22:04:15 +02:00
entry: [
2017-07-24 16:18:43 +02:00
'./src/scripts/src/choices'
2016-09-15 22:04:15 +02:00
],
output: {
2017-07-24 16:18:43 +02:00
path: path.join(__dirname, '/src/scripts/dist'),
2016-09-15 22:04:15 +02:00
filename: minimize ? 'choices.min.js' : 'choices.js',
2017-07-24 16:18:43 +02:00
publicPath: '/src/scripts/dist/',
2016-10-18 15:15:00 +02:00
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'],
2017-07-24 16:18:43 +02:00
include: path.join(__dirname, 'src/scripts/src')
2016-09-15 22:04:15 +02:00
}]
}
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;