-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathwebpack.prod.config.babel.js
66 lines (61 loc) · 1.91 KB
/
webpack.prod.config.babel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* eslint-disable import/no-extraneous-dependencies */
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const DefinePlugin = new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
});
const CleanPlugin = new CleanWebpackPlugin(['public']);
const HTMLWebpackPluginConfig = new HtmlWebpackPlugin({ template: 'index.html' });
const UglifyPlugin = new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } });
const DedupePlugin = new webpack.optimize.DedupePlugin();
const CommonChunksPlugin = new webpack.optimize.CommonsChunkPlugin({ names: ['vendor', 'manifest'] });
const CopyWebpackPluginConfig = new CopyWebpackPlugin([
{ from: 'manifest.json' },
{ from: 'favicon.ico' },
{ from: 'sw.js' },
{ from: 'src/images/icons', to: 'images' },
]);
const ExtractText = new ExtractTextPlugin('styles.css');
module.exports = {
entry: {
vendor: ['react', 'react-dom'],
app: './src/index.js',
},
output: {
path: 'public',
filename: '[name].js',
},
resolve: {
alias: {
react: 'preact-compat',
'react-dom': 'preact-compat',
},
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
},
{
test: /\.scss$/,
loader: ExtractText.extract(
'style',
'css?modules&importLoaders=1&localIdentName=[hash:base64:5]',
),
},
{
test: /.(png|woff(2)?|eot|otf|ttf|svg)(\?[a-z0-9=\.]+)?$/,
loader: 'url-loader?limit=100000',
},
],
},
plugins: [CleanPlugin, DefinePlugin, HTMLWebpackPluginConfig, UglifyPlugin, DedupePlugin,
ExtractText, CopyWebpackPluginConfig, CommonChunksPlugin],
};