-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
126 lines (114 loc) · 2.89 KB
/
webpack.config.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
require('babel-register');
const path = require('path');
const webpack = require('webpack');
const swiss = require('kouto-swiss');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ReactStaticPlugin = require('react-static-webpack-plugin');
const isDev = process.env.NODE_ENV !== 'production';
const stylesheet = isDev ? null : 'main.css';
const localIdentName = isDev ?
'&localIdentName=[name]__[local]__[hash:base64:6]' :
'';
const plugins = [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(isDev ? 'development' : 'production')
},
__DEVTOOLS__: !isDev
}),
// Use browser version of visionmedia-debug
new webpack.NormalModuleReplacementPlugin(
/debug\/node/,
'debug/browser'
),
new webpack.optimize.OccurenceOrderPlugin(true)
];
const devPlugins = [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
];
const prodPlugins = [
new ExtractTextPlugin(stylesheet, { allChunks: true }),
new webpack.optimize.UglifyJsPlugin({
/* eslint-disable camelcase */
screw_ie8: true,
/* eslint-enable camelcase */
compressor: { warnings: false }
}),
new ReactStaticPlugin({
component: './client/components/App.jsx',
template: './template.jsx',
reduxStore: './client/index.js',
stylesheet
})
];
const stylLoaders = [
'style',
`css?modules&importLoaders=1${localIdentName}`,
'stylus'
];
const cssLoaders = [
'style',
`css?modules${localIdentName}`
];
module.exports = {
devtool: isDev ? 'inline-source-map' : null,
entry: {
bundle: [ './client/index.js' ]
},
output: {
filename: 'bundle.js',
path: path.join(__dirname, 'public'),
publicPath: '/'
},
plugins: plugins.concat(isDev ? devPlugins : prodPlugins),
module: {
loaders: [
{
test: /\.jsx?$/,
include: [
path.join(__dirname, 'client/'),
path.join(__dirname, './template.jsx')
],
loaders: isDev ? ['react-hot', 'babel'] : [ 'babel' ]
},
{
test: /\.json$/,
loaders: [
'json-loader'
]
}, {
test: /\.css/,
loader: isDev ?
cssLoaders.join('!') :
ExtractTextPlugin.extract(cssLoaders[0], cssLoaders.slice(1))
}, {
test: /\.styl$/,
loader: isDev ?
stylLoaders.join('!') :
ExtractTextPlugin.extract(stylLoaders[0], stylLoaders.slice(1))
},
{
test: /\.(ttf|eot|woff2?)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loaders: [
'file?name=[name].[ext]'
]
},
{
test: /\.(png|jpg|gif|ico|svg|mp4|webm)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loaders: [
'file?name=[name].[ext]'
]
}
]
},
stylus: {
use: [
swiss()
],
import: [
'~kouto-swiss/lib/kouto-swiss/index.styl',
path.join(__dirname, '/client/globals.styl')
]
}
};