-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
60 lines (52 loc) · 1.37 KB
/
next.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
const webpack = require('webpack')
const path = require('path')
const glob = require('glob')
const rules = [
{
test: /\.(css|less)/,
loader: 'emit-file-loader',
options: {
name: 'dist/[path][name].[ext]'
}
}
]
const production = [
new webpack.optimize.DedupePlugin(), // dedupe similar code
new webpack.optimize.AggressiveMergingPlugin() // Merge chunks
]
module.exports = {
webpack: (config, { dev }) => {
rules.forEach(rule => {
config.module.rules.push(rule)
})
if (dev) {
return Object.assign({}, config, { devtool: 'cheap-module-source-map' })
}
// use react-lite in production client-side
// config.resolve.alias = {
// react: 'react-lite',
// 'react-dom': 'react-lite',
// 'create-react-class': 'react-lite/lib/createClass'
// }
production.forEach(plugin => {
config.plugins.push(plugin)
})
// config.plugins = config.plugins.filter(
// plugin => plugin.constructor.name !== 'UglifyJsPlugin'
// )
//
// config.plugins.push(
// new ClosureCompilerPlugin({
// compiler: {
// language_in: 'ECMASCRIPT6',
// language_out: 'ECMASCRIPT5',
// compilation_level: 'ADVANCED'
// },
// concurrency: 3
// })
// )
return config
},
production,
rules
}