-
Notifications
You must be signed in to change notification settings - Fork 24
/
webpack.config.prod.js
87 lines (79 loc) · 2.03 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
/* eslint-disable no-var */
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var axis = require('axis');
var rupture = require('rupture');
var execSync = require('child_process').execSync;
var ReactStaticPlugin = require('../../dist');
module.exports = {
devtool: 'source-map',
context: __dirname,
entry: {
app: [
'babel-polyfill',
'./src/index.js',
],
},
output: {
path: path.join(__dirname, 'public'),
filename: '[name].js',
publicPath: '/',
},
plugins: [
new ExtractTextPlugin('[name].css', { allChunks: true }),
// new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
__VERSION__: JSON.stringify(execSync('git describe', { encoding: 'utf-8' }).trim()),
},
}),
new webpack.optimize.UglifyJsPlugin({
screw_ie8: true,
compressor: { warnings: false },
}),
// Generate the static site
new ReactStaticPlugin({
routes: './src/routes.js',
reduxStore: './src/redux/store.js',
template: './template.js',
}),
],
module: {
loaders: [
{
test: /\.js$/,
loaders: ['babel'],
exclude: path.join(__dirname, 'node_modules'),
},
{
test: /\.json$/,
loaders: ['json'],
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css'),
},
{
test: /\.styl/,
loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=2!autoprefixer!stylus'),
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loaders: ['url?limit=10000&mimetype=application/font-woff'],
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loaders: ['file'],
},
{
test: /\.(png|jpg|gif|ico)$/,
loaders: ['file?name=[name].[ext]'],
},
],
},
stylus: {
use: [axis(), rupture()],
},
};