-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
95 lines (91 loc) · 1.83 KB
/
webpack.config.babel.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
/**
* webpack configuration.
* @file
*/
import config from './config'
import path from 'path'
import webpack from 'webpack'
import CircularDependencyPlugin from 'circular-dependency-plugin'
import fs from 'fs'
const {
NODE_ENV,
rootPath,
distPath,
srcPath,
srcClientPath,
srcCommonPath,
srcServerPath
} = config
const definePluginArgs = {
'process.env.NODE_ENV': JSON.stringify(NODE_ENV)
}
let nodeModules = {}
fs
.readdirSync('node_modules')
.filter(x => {
return ['.bin'].indexOf(x) === -1
})
.forEach(mod => {
nodeModules[mod] = 'commonjs ' + mod
})
export default {
devtool: 'source-map',
name: 'server',
entry: path.join(srcPath, 'server/app.js'),
target: 'node',
node: {
__dirname: false,
__filename: false
},
output: {
path: distPath,
filename: 'app.bundle.js'
},
externals: nodeModules,
module: {
rules: [
{
test: /\.(js|jsx)$/,
enforce: 'pre',
use: [
{
loader: 'eslint-loader',
options: {
fix: true
}
}
],
exclude: [/node_modules/]
},
{
test: /\.(js|jsx)$/,
use: [
'babel-loader'
],
exclude: [/node_modules/]
}
]
},
plugins: [
new CircularDependencyPlugin({
exclude: /node_modules/
}),
new webpack.optimize.UglifyJsPlugin({
minimize: true,
compress: {
warnings: false
}
}),
new webpack.DefinePlugin(definePluginArgs)
],
resolve: {
extensions: ['.js', '.json', '.jsx'],
alias: {
client: path.join(srcClientPath),
common: path.join(srcCommonPath),
controller: path.join(srcServerPath, '/controller'),
routes: path.join(srcServerPath, '/routes')
},
modules: [srcPath, path.join(rootPath, 'node_modules')]
}
}