-
Notifications
You must be signed in to change notification settings - Fork 36
/
webpack.config.prod.js
96 lines (90 loc) · 2.35 KB
/
webpack.config.prod.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const path = require('path');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const OfflinePlugin = require('offline-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
module.exports = {
devtool: 'source-map',
entry: [
'./src/index.jsx'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
},
plugins: [
/**
* This plugin assigns the module and chunk ids by occurence count. What this
* means is that frequently used IDs will get lower/shorter IDs - so they become
* more predictable.
*/
new webpack.optimize.OccurrenceOrderPlugin(),
/**
* See description in 'webpack.config.dev' for more info.
*/
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new LodashModuleReplacementPlugin(),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
new ExtractTextPlugin('styles.css'),
new HtmlWebpackPlugin({
production: true,
inject: false,
template: './src/index.html'
}),
/**
* Add a service worker
*/
new OfflinePlugin({
ServiceWorker: {events: true},
AppCache: false
})
],
resolve: {
extensions: ['.js', '.jsx', '.json'],
alias: {
'react': 'preact-compat',
'react-dom': 'preact-compat'
}
},
module: {
loaders: [
{
test: /\.jsx?$/,
loaders: ['babel-loader'],
include: [
path.join(__dirname, 'src'),
path.join(__dirname, './node_modules/preact-compat')
]
},
{
test: /\.(jpg|jpeg|png)$/,
loaders: [
'file-loader?name=static/[name].[hash].[ext]'
],
include: path.join(__dirname, 'static')
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: 'style-loader',
loader: [
{loader: 'css-loader'},
{loader: 'postcss-loader'},
{loader: 'sass-loader'}
]
})
},
{
test: /\.svg$/,
loader: 'url-loader?limit=8192!svgo-loader'
}
]
}
};