434f45c97c
* Less repetition in webpack configs. Minify CSS classnames in production. * Ignore all optional deps of moment.js. Fixes #138 * Added target to webpack config * Automatically extract all 3rd party modules into a separate 'vendor' chunk * Inline only assets that are smaller than 10KB * Added autoprefixer options * Replaced sinfle babel transforms with the stage-1 preset. Cleaned up webpack configs. * Do not include hot module replacement in production
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
/* global module, __dirname, require */
|
|
const path = require('path');
|
|
const webpack = require('webpack');
|
|
const merge = require('webpack-merge');
|
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
|
|
module.exports = merge.smart(require('./webpack.base.js'), {
|
|
entry: {
|
|
cms: './index',
|
|
},
|
|
output: {
|
|
path: path.join(__dirname, 'dist'),
|
|
filename: '[name].js',
|
|
},
|
|
module: {
|
|
loaders: [
|
|
{
|
|
test: /\.css$/,
|
|
loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=1!postcss'), // Use minified class names on production
|
|
},
|
|
],
|
|
},
|
|
context: path.join(__dirname, 'src'),
|
|
plugins: [
|
|
new webpack.DefinePlugin({
|
|
'process.env': {
|
|
NODE_ENV: JSON.stringify('production'),
|
|
},
|
|
}),
|
|
new webpack.optimize.OccurenceOrderPlugin(),
|
|
|
|
// Minify and optimize the JavaScript
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
compress: {
|
|
// ...but do not show warnings in the console (there is a lot of them)
|
|
warnings: false,
|
|
},
|
|
}),
|
|
|
|
// Extract CSS
|
|
new ExtractTextPlugin('[name].css', { allChunks: true }),
|
|
|
|
// Automatically extract all 3rd party modules into a separate 'vendor' chunk
|
|
new webpack.optimize.CommonsChunkPlugin({
|
|
name: 'vendor',
|
|
minChunks: ({ resource }) => /node_modules/.test(resource),
|
|
}),
|
|
],
|
|
});
|