-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.config.js
More file actions
62 lines (55 loc) · 1.53 KB
/
webpack.config.js
File metadata and controls
62 lines (55 loc) · 1.53 KB
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
//webpack client config
const {resolve} = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const config = require('./webpack.common.config')
const isDev = process.env.NODE_ENV == 'development'
//development
if (isDev) {
config.devtool = 'cheap-module-eval-source-map'
config.entry = [
'webpack-hot-middleware/client?path=http://127.0.0.1:3001/__webpack_hmr',
'react-hot-loader/patch',
'babel-polyfill',
'./src/index.js'
]
config.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin()
)
config.devServer = {
hot: true,
contentBase: resolve(__dirname, './public'),
publicPath: '/'
}
config.module.rules.push({
test: /\.(css|sass|scss)/,
use: ['style-loader', 'css-loader', 'sass-loader']
})
}
//production
if (!isDev) {
config.entry = './src/index.js'
config.plugins.push(
new ExtractTextPlugin('style.css'),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}))
config.module.rules.push({
test: /\.(css|sass|scss)/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader!sass-loader'
}
)
})
}
config.module.rules.push({
test: /\.(js|jsx)$/,
exclude: /(node_modules)/,
enforce: 'pre',
loader: 'eslint-loader',
})
module.exports = config