-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathrsbuild.config.js
More file actions
87 lines (83 loc) · 2.26 KB
/
Copy pathrsbuild.config.js
File metadata and controls
87 lines (83 loc) · 2.26 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
/*
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
const { defineConfig } = require('@rsbuild/core')
const { pluginVue } = require('@rsbuild/plugin-vue')
const { pluginSass } = require('@rsbuild/plugin-sass')
const { pluginNodePolyfill } = require('@rsbuild/plugin-node-polyfill')
const path = require('node:path')
module.exports = defineConfig((context = {}) => {
const env = context.env || {}
const isDev =
Boolean(env.development) ||
(!env.production && process.env.NODE_ENV === 'development')
if (isDev) {
console.log('Building in development mode')
} else {
console.log('Building in production mode')
}
return {
plugins: [
pluginVue(),
pluginSass(),
pluginNodePolyfill(),
],
source: {
entry: {
main: path.resolve(__dirname, 'src', 'main.js'),
globalSettings: path.resolve(__dirname, 'src', 'globalSettings.js'),
},
},
output: {
distPath: {
root: path.resolve(__dirname, 'js'),
js: '.',
},
filename: {
js: `${process.env.npm_package_name}-[name].js?v=[contenthash]`,
},
chunkFilename: `${process.env.npm_package_name}-[name].js?v=[contenthash]`,
assetModuleFilename: '[name][ext]',
publicPath: 'auto',
injectStyles: true,
clean: true,
legalComments: 'none',
devtoolNamespace: process.env.npm_package_name,
devtoolModuleFilenameTemplate(info) {
const rootDir = process.cwd()
const rel = path.relative(rootDir, info.absoluteResourcePath)
return `webpack:///${process.env.npm_package_name}/${rel}`
},
},
define: {
IS_DESKTOP: false,
__IS_DESKTOP__: false,
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: false,
__webpack_public_path__: JSON.stringify(process.env.WEBPACK_PUBLIC_PATH || `/apps/${process.env.npm_package_name}/js/`),
appName: JSON.stringify(process.env.npm_package_name),
appVersion: JSON.stringify(process.env.npm_package_version),
},
resolve: {
extensions: ['.js', '.vue', '.json'],
},
tools: {
rspack: {
cache: true,
devtool: isDev ? 'source-map' : false,
resolve: {
symlinks: false,
fallback: {
fs: false,
},
},
optimization: {
splitChunks: false,
minimize: !isDev,
},
},
htmlPlugin: false,
},
}
})