-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.server.config.js
84 lines (80 loc) · 2.67 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const path = require('path');
const webpack = require("webpack");
const webpackMerge = require('webpack-merge');
const nodeExternals = require('webpack-node-externals');
const commonConfig = require('./webpack.common.config');
const babelConfig = require('./babel.server.config');
const postCssConfig = require('./postcss.config');
const isDebug = !process.argv.includes('--publish');
const isCssClassNameObfuscationEnabled = false;
const serverConfig = webpackMerge(
commonConfig,
{
name: 'server',
target: 'node',
mode: isDebug ? 'development' : 'production',
entry: {
server: [
path.resolve(__dirname, 'src/server/server.js')
],
},
output: {
path: path.resolve(__dirname, 'build/server'),
filename: '[name].js',
libraryTarget: 'commonjs2'
},
module: {
rules: [
{
test: /\.(js|jsx|mjs)$/,
loader: "babel-loader",
include: [
path.resolve(__dirname, 'src')
],
options: {
cacheDirectory: true,
babelrc: false,
...babelConfig
}
},
{
test: /\.scss$/,
use: [
{
loader: 'css-loader/locals',
options: {
modules: true,
importLoaders: 1,
sourceMap: isDebug,
localIdentName: isCssClassNameObfuscationEnabled
? '[hash:base64:5]'
: '[name]-[local]',
minimize: isDebug,
}
},
{
loader: 'postcss-loader',
options: postCssConfig
},
{
loader: 'sass-loader'
}
]
}
],
},
externals: [nodeExternals()],
plugins: [
new webpack.DefinePlugin({
'process.env.BROWSER': false,
__DEV__: isDebug,
}),
...(
isDebug ? [
new webpack.HotModuleReplacementPlugin(),
] :
[]
),
]
});
module.exports = serverConfig;