Created
April 13, 2017 12:06
-
-
Save jacek213/ab575fe66288fb224d426459ed0ede0b to your computer and use it in GitHub Desktop.
webpack config prod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path') | |
const webpack = require('webpack') | |
const HtmlWebpackPlugin = require('html-webpack-plugin') | |
const ExtractTextPlugin = require('extract-text-webpack-plugin') | |
const CleanWebpackPlugin = require('clean-webpack-plugin') | |
module.exports = { | |
context: __dirname, | |
entry: './src/index.js', | |
output: { | |
path: path.join(__dirname, '/dist'), | |
publicPath: '/', | |
filename: 'bundle.[hash:8].js' | |
}, | |
resolve: { | |
extensions: ['.js', '.jsx', '.json'] | |
}, | |
stats: { | |
colors: true, | |
reasons: true, | |
chunks: false | |
}, | |
module: { | |
rules: [ | |
{ | |
enforce: "pre", | |
test: /\.js$/, | |
loader: "eslint-loader", | |
exclude: /node_modules/ | |
}, | |
{ | |
test: /\.js?$/, | |
loader: 'babel-loader', | |
include: [ | |
path.resolve('src') | |
] | |
}, | |
{ | |
test: /\.scss?$/, | |
use: ExtractTextPlugin.extract({ | |
fallback: 'style-loader', | |
use: ['css-loader', 'sass-loader'] | |
}), | |
// loaders: [ | |
// "style-loader", | |
// "css-loader", | |
// "sass-loader" | |
// ], | |
include: [ | |
path.resolve('src') | |
] | |
}, | |
{ | |
test: /\.(jpg|png)$/, | |
loader: 'file-loader' | |
}, | |
{ | |
test: /\.json$/, | |
loader: 'json-loader' | |
} | |
] | |
}, | |
plugins: [ | |
new CleanWebpackPlugin(['dist'], { | |
root: __dirname, | |
verbose: true, | |
dry: false, | |
exclude: [] | |
}), | |
// https://www.npmjs.com/package/html-webpack-plugin | |
new HtmlWebpackPlugin({ | |
title: 'Hizzy', | |
template: '!!html-loader!src/index.html' | |
}), | |
new ExtractTextPlugin('styles.css'), | |
new webpack.optimize.CommonsChunkPlugin({ | |
name: "commons", | |
// (the commons chunk name) | |
// template: path.join(__dirname, 'public', 'index.html'), | |
filename: "commons.[hash:8].js", | |
// (the filename of the commons chunk) | |
// minChunks: 3, | |
// (Modules must be shared between 3 entries) | |
// chunks: ["pageA", "pageB"], | |
// (Only use these entries) | |
}), | |
new webpack.optimize.UglifyJsPlugin(), | |
new webpack.optimize.AggressiveMergingPlugin() | |
], | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment