-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathwebpack.server.config.js
More file actions
124 lines (120 loc) · 4.42 KB
/
webpack.server.config.js
File metadata and controls
124 lines (120 loc) · 4.42 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const path = require("path");
const config = require("./config/default");
const nodeExternals = require("webpack-node-externals");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
module.exports = {
mode: "production",
name: "server",
target: "node",
// devtool: "source-map", // If you enable this while developing, you MUST disable it again before commiting as it uses too much memory during produciton build
externalsPresets: { node: true }, // in order to ignore built-in modules like path, fs, etc.
externals: {
express: "commonjs2 express",
ws: "commonjs2 ws",
},
entry: {
server: "./src/server/server.tsx",
generateSitemapScript: "./generate-sitemap.ts",
},
output: {
filename: "[name].js",
path: path.resolve(__dirname, config.buildConfig.targetDir),
},
module: {
rules: [
{
test: /\.css?$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "postcss-loader"],
exclude: /node_modules/,
},
{
test: /\.scss$/,
use: [
{ loader: MiniCssExtractPlugin.loader },
{
loader: "css-loader",
options: {
modules: {
localIdentName: "[hash:base64:5]",
},
},
},
{
loader: "postcss-loader",
},
{
loader: "sass-loader",
},
],
exclude: /node_modules/,
},
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.(png|svg|jpg|gif)$/,
type: "asset/resource",
generator: {
// Generator options for asset modules
// Emit an output asset from this asset module. This can be set to 'false' to omit emitting e. g. for SSR.
// type: boolean
emit: false,
filename: "[name][ext]",
// // Customize publicPath for asset modules, available since webpack 5.28.0
// // type: string | ((pathData: PathData, assetInfo?: AssetInfo) => string)
publicPath: "images/",
// // Emit the asset in the specified folder relative to 'output.path', available since webpack 5.67.0
// // type: string | ((pathData: PathData, assetInfo?: AssetInfo) => string)
outputPath: "images/",
},
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
alias: {
scichart: path.resolve(__dirname, "./node_modules/scichart"),
"scichart-addons": path.resolve(__dirname, "../Addons"),
},
},
optimization: {
minimizer: [
// For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
`...`,
new CssMinimizerPlugin(),
],
},
// performance: {
// maxAssetSize: 2000000, // Sets the maximum individual asset size to 2MB (in bytes)
// maxEntrypointSize: 2000000, // Sets the maximum entry point size to 2MB (in bytes)
// },
plugins: [
new CopyPlugin({
patterns: [
{
from: "Examples/**/*",
context: path.resolve(__dirname, "src", "components"),
globOptions: {
dot: true,
gitignore: false,
ignore: [
"**/exampleInfo.*",
"**/*.jpg",
"**/*.png",
"**/ExamplesRoot.tsx",
"**/ExampleStrings.ts",
],
},
},
],
}),
new MiniCssExtractPlugin({
filename: "style.css",
}),
require("autoprefixer"),
],
};