-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.server.config.js
executable file
·107 lines (102 loc) · 2.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
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
96
97
98
99
100
101
102
103
104
105
106
107
var webpack = require("webpack"),
path = require("path"),
CopyWebpackPlugin = require("copy-webpack-plugin"),
HtmlWebpackPlugin = require("html-webpack-plugin"),
TerserPlugin = require("terser-webpack-plugin");
var { CleanWebpackPlugin } = require("clean-webpack-plugin");
const ASSET_PATH = process.env.ASSET_PATH || "/";
const isDevelopment = process.env.NODE_ENV !== "production";
const options = {
target: "node",
mode: process.env.NODE_ENV || "development",
entry: {
index: path.join(__dirname, "server", "index.tsx"),
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.css', '.scss', '.png', '.svg'],
},
output: {
filename: "[name].bundle.js",
path: path.resolve(__dirname, "build", "server"),
clean: true,
publicPath: ASSET_PATH,
},
module: {
rules: [
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
publicPath: 'assets',
bypassOnDebug: true, // [email protected]
disable: true, // [email protected] and newer
},
},
],
},
{
// look for .css or .scss files
test: /\.(css|scss)$/,
// in the `web` directory
use: [
{
loader: "style-loader",
},
{
loader: "css-loader",
options: { importLoaders: 1 },
},
{
loader: "postcss-loader",
},
{
loader: "sass-loader",
options: {
sourceMap: true,
},
},
],
},
{
test: /\.node$/,
use: 'node-loader',
},
{
test: /\.(ts|tsx)$/,
exclude: /node_modules\/(?!(tlsn-js|tlsn-js-v5)\/).*/,
use: [
{
loader: require.resolve("ts-loader"),
options: {
transpileOnly: isDevelopment,
},
},
],
},
],
},
plugins: [
new CleanWebpackPlugin({ verbose: false }),
new webpack.ProgressPlugin(),
new webpack.EnvironmentPlugin(["NODE_ENV"]),
].filter(Boolean),
infrastructureLogging: {
level: "info",
},
};
if (process.env.NODE_ENV === "development") {
options.devtool = "cheap-module-source-map";
} else {
options.optimization = {
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false,
}),
],
};
}
module.exports = options;