-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrspack.config.js
107 lines (106 loc) · 2.64 KB
/
rspack.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
// @ts-check
const { VueLoaderPlugin } = require("vue-loader");
const path = require("path");
const EslintPlugin = require("eslint-webpack-plugin");
const rspack = require("@rspack/core");
const { RsdoctorRspackPlugin } = require("@rsdoctor/rspack-plugin");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const Dotenv = require("dotenv-webpack");
const isProduction = process.env.NODE_ENV == "production";
/** @type {import('@rspack/cli').Configuration} */
module.exports = {
context: __dirname,
devtool: "inline-source-map",
output: {
path:path.resolve(__dirname,"dist")
},
plugins: [
isProduction && new RsdoctorRspackPlugin({}),
isProduction && new BundleAnalyzerPlugin(),
new Dotenv({
path: path.resolve(__dirname, `.env.${process.env.NODE_ENV || "development"}`),
}),
new rspack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
"process.env.DEBUG": JSON.stringify(process.env.DEBUG),
}),
new EslintPlugin({
files: path.resolve(__dirname, "src"),
rulePaths: [__dirname],
}),
new VueLoaderPlugin(),
new rspack.HtmlRspackPlugin({
template: "./index.html",
}),
],
optimization: {
realContentHash: true,
minimize: isProduction,
minimizer: [
new rspack.SwcJsMinimizerRspackPlugin({
format: {
comments: false,
},
compress:{
drop_console:true,
drop_debugger:true,
}
}),
new rspack.SwcCssMinimizerRspackPlugin(),
],
},
entry: {
main: path.resolve(__dirname, "src", "main.ts"),
},
resolve: {
extensions: ["...", ".ts", ".vue"],
alias: {
"@": path.resolve(__dirname, "src"),
},
},
module: {
rules: [
{
test: /\.vue$/,
use: [
{
loader: "vue-loader",
options: {
// 注意,为了绝大多数功能的可用性,请确保该选项为 `true`
experimentalInlineMatchResource: true,
},
},
],
},
{
test: /\.less$/,
use: ["postcss-loader", "less-loader"],
type: "css",
},
{
test: /\.css$/,
use: ["postcss-loader"],
type: "css",
},
{
test: /\.(ts|js)$/,
exclude: [/node_modules/],
loader: "builtin:swc-loader",
options: {
jsc: {
parser: {
syntax: "typescript",
topLevelAwait: true,
},
},
minify: true,
},
type: "javascript/auto",
},
],
},
devServer: {
port: "3030",
open: true,
},
};