-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.server.config.js
53 lines (52 loc) · 1.49 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
const path = require('path')
const webpack = require('webpack')
const webpackNodeExternals = require('webpack-node-externals')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
require('dotenv').config()
module.exports = (e, r) => {
return {
target: 'node',
node: false, // it enables '__dirname' in files. If is not, '__dirname' always return '/'.
mode: r.mode,
devtool: r.mode === 'production' ? false : 'inline-source-map',
entry: {
index: path.resolve(__dirname, 'server', 'index.ts')
},
output: {
path: path.resolve(__dirname, './dist'),
filename: '[name].js',
chunkFilename: '[name].js'
},
module: {
rules: [
{
test: /\.s?css$/i,
exclude: /\.module\.s?css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
}, // CSS Module ([filename].module.css)
{
test: /\.module\.s?css$/i,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: true
}
},
'sass-loader'
]
},
{
test: /\.jsx?$|\.tsx?$/,
use: 'babel-loader'
}
]
},
resolve: {
extensions: ['.js', '.ts', '.tsx', '.jsx']
},
plugins: [new MiniCssExtractPlugin(), new webpack.DefinePlugin({ 'process.env': JSON.stringify(process.env) })],
externals: [webpackNodeExternals()]
}
}