forked from 5tefan/universal-react-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.server.config.js
54 lines (52 loc) · 1.46 KB
/
webpack.server.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
const webpack = require('webpack');
// builtin node path module
const path = require('path');
const node_env = process.env.NODE_ENV || 'dev';
console.log("-------->",process.env.NODE_ENV);
module.exports = {
devtool: node_env == 'prod' ? false : "#source-map",
target: "node",
cache: false,
context: __dirname,
resolve: {
alias: {
"~": path.join(__dirname, './app')
},
extensions: ['.js', '.jsx']
},
entry: path.join(__dirname, 'server.js') ,
//入口文件是server.js,而且target是'node'
output: {
path: path.join(__dirname, './build'),
filename: 'server.js',
},
module: {
loaders: [
{
test: /\.jsx*$/,
exclude: /(node_modules|bower_components)/,
loaders: ["babel-loader?presets[]=es2015&presets[]=stage-0&presets[]=react"]
}, {
test: /\.scss$/,
loader: 'css-loader/locals?modules&loacalIdentName=[name]--[local]--[hash:base64:5]!sass-loader'
}, {
test: /\.json$/,
loader: 'json-loader'
}]
},
plugins: [
new webpack.DefinePlugin({
// http://stackoverflow.com/a/35372706/2177568
// for server side code, just require, don't chunk
// use `if (ONSERVER) { ...` for server specific code
ONSERVER: true
}),
new webpack.LoaderOptionsPlugin({
options: {
sassLoader: {
includePaths: [path.resolve(__dirname, "./node_modules/compass-mixins/lib")]
}
}
})
],
}