-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.server.config.js
62 lines (59 loc) · 1.66 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
55
56
57
58
59
60
61
62
'use strict';
var path = require('path');
var webpack = require('webpack');
var nodeExternals = require('webpack-node-externals');
var isProduction = process.env.NODE_ENV === 'production';
var productionPluginDefine = isProduction ? [
new webpack.DefinePlugin({'process.env': {'NODE_ENV': JSON.stringify('production')}})
] : [];
console.log('[webpack.server.config.js] __dirname: ', __dirname)
console.log('[webpack.server.config.js] process.cwd(): ', process.cwd())
module.exports = {
devtool: 'sourcemap',
entry: './server/index.js',
output: {
path: path.resolve('./server/dist/'),
filename: 'build.js',
libraryTarget: 'commonjs2',
publicPath: '../public'
},
target: 'node',
node: {
console: false,
global: false,
process: false,
Buffer: false,
__filename: false,
__dirname: false
},
externals: nodeExternals(),
plugins: [
new webpack.BannerPlugin({
banner: 'require("source-map-support").install();',
raw: true,
entryOnly: false
})
],
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
"plugins": ["add-module-exports", "transform-decorators-legacy", "jsx-control-statements"],
"presets": ["env", "react", "stage-0"]
}
},
{
test: /\.json?$/,
loader: 'json-loader'
}, {
test: /\.less$/,
use: ["css-loader/locals?modules&importLoaders=1&localIdentName=[name]---[local]---[hash:base64:5]", "less-loader"]
}, {
test: /\.css$/,
loader: "css-loader/locals?modules&importLoaders=1&localIdentName=[name]---[local]---[hash:base64:5]"
}
]
}
}