webpack.production.config.js
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
devtool: 'source-map',
entry: [
'./src/index',
],
output: {
path: path.join(__dirname, 'docs'),
filename: 'bundle.js',
},
resolve: {
extensions: ['', '.scss', '.css', '.js', '.jsx'],
},
module: {
loaders: [
{
test: /.jsx?$/,
loader: 'babel',
include: path.join(__dirname, 'src'),
},
{
test: /(\.scss|\.css)$/,
loader: ExtractTextPlugin.extract('style', 'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass'),
},
],
},
sassLoader: {
data: '@import "theme/_config.scss";',
includePaths: [path.resolve(__dirname, './sass')],
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }),
new HtmlWebpackPlugin({
template: './src/index.template.html',
filename: 'index.html',
}),
new ExtractTextPlugin('theme.css', { allChunks: true }),
],
};