Note: The output.library
and name
(in DllPlugin) must be the same.
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractCSS = new ExtractTextPlugin('vendor.css');
const isDevelopment = process.env.NODE_ENV !== 'production';
module.exports = {
resolve: {
extensions: ['.js'],
},
module: {
rules: [
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' },
{ test: /\.s?css$/i, loader: extractCSS.extract(['css-loader?minimize', 'sass-loader']) },
{ test: /\.json$/, loader: 'json-loader' },
],
},
entry: {
vendor: [
'babel-polyfill',
'font-awesome/scss/font-awesome.scss',
'bootstrap/scss/bootstrap.scss',
'jquery',
'history',
'react',
'react-dom',
'redux',
'react-redux',
'react-router',
'react-router-dom',
'react-router-redux',
'redux-thunk',
],
},
output: {
path: path.resolve('./dist'),
filename: '[name].js',
library: '[name]_[hash]',
},
plugins: [
extractCSS,
new webpack.DllPlugin({
path: path.join(__dirname, 'dist', '[name]-manifest.json'),
name: '[name]_[hash]',
})
].concat(isDevelopment ? [] : [
new webpack.optimize.UglifyJsPlugin({
beautify: false,
comments: false,
}),
]),
};