-
Notifications
You must be signed in to change notification settings - Fork 9
refactor: migrate from rspack to rsbuild for build configuration #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
R0Wi
commented
Dec 22, 2025
- Updated package.json to replace rspack commands with rsbuild equivalents.
- Removed rspack.config.js and added rsbuild.config.js with new configuration.
- Adjusted linting scripts to ensure proper file matching.
- Updated dependencies to align with rsbuild requirements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR migrates the build configuration from rspack to rsbuild, modernizing the build tooling while maintaining the same entry points and overall structure. The migration simplifies the configuration by leveraging rsbuild's higher-level abstractions and plugin system.
- Replaced rspack CLI commands with rsbuild equivalents in npm scripts
- Converted rspack.config.js to rsbuild.config.js using rsbuild plugins
- Updated dependencies to use @rsbuild packages instead of @rspack
- Fixed escaped asterisk in stylelint glob pattern
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| rspack.config.js | Removed the old rspack configuration file (169 lines) |
| rsbuild.config.js | Added new rsbuild configuration with plugins for Vue, Sass, and Node polyfills |
| package.json | Updated build/dev/watch scripts to use rsbuild commands, replaced rspack dependencies with rsbuild equivalents, changed browserslist config, and fixed lint script glob pattern |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }, | ||
| "browserslist": [ | ||
| "extends @nextcloud/browserslist-config" | ||
| "last 2 major versions" |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The browserslist configuration has changed from 'extends @nextcloud/browserslist-config' to 'last 2 major versions'. This is a significant change that could affect browser compatibility. The new configuration is much more permissive and might not align with Nextcloud's supported browser policy. This change should be intentional and documented, or should continue to use the @nextcloud/browserslist-config to maintain consistency with the Nextcloud ecosystem.
| "last 2 major versions" | |
| "extends @nextcloud/browserslist-config" |
rsbuild.config.js
Outdated
| module.exports = defineConfig({ | ||
| 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: '/apps/workflow_ocr/js/', | ||
| 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__: '/apps/workflow_ocr/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, | ||
| resolve: { | ||
| symlinks: false, | ||
| fallback: { | ||
| fs: false, | ||
| }, | ||
| }, | ||
| optimization: { | ||
| splitChunks: false, | ||
| }, | ||
| }, | ||
| htmlPlugin: false, | ||
| }, |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old rspack configuration had a sophisticated mode detection system that checked env.development, env.production, and process.env.NODE_ENV with a default of 'production'. It also had separate devtool settings and minimizer configuration based on the isDev flag. The new rsbuild configuration doesn't explicitly handle development vs production mode, which means the 'dev' script (line 17) that passes '--env development' may not work as expected since rsbuild.config.js doesn't use or process environment flags.
| module.exports = defineConfig({ | |
| 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: '/apps/workflow_ocr/js/', | |
| 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__: '/apps/workflow_ocr/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, | |
| resolve: { | |
| symlinks: false, | |
| fallback: { | |
| fs: false, | |
| }, | |
| }, | |
| optimization: { | |
| splitChunks: false, | |
| }, | |
| }, | |
| htmlPlugin: false, | |
| }, | |
| module.exports = defineConfig((context = {}) => { | |
| const env = context.env || {} | |
| const isDev = | |
| Boolean(env.development) || | |
| (!env.production && process.env.NODE_ENV === 'development') | |
| 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: '/apps/workflow_ocr/js/', | |
| 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__: '/apps/workflow_ocr/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 ? 'eval-source-map' : false, | |
| resolve: { | |
| symlinks: false, | |
| fallback: { | |
| fs: false, | |
| }, | |
| }, | |
| optimization: { | |
| splitChunks: false, | |
| minimize: !isDev, | |
| }, | |
| }, | |
| htmlPlugin: false, | |
| }, | |
| } |
rsbuild.config.js
Outdated
| js: `${process.env.npm_package_name}-[name].js?v=[contenthash]`, | ||
| }, | ||
| chunkFilename: `${process.env.npm_package_name}-[name].js?v=[contenthash]`, | ||
| assetModuleFilename: '[name][ext]', |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assetModuleFilename is missing the version hash that was present in the old configuration. The old config had '[name][ext]?v=[contenthash]' while the new config only has '[name][ext]'. This means asset files won't have cache-busting query strings, which could lead to browser caching issues when assets are updated.
| assetModuleFilename: '[name][ext]', | |
| assetModuleFilename: '[name][ext]?v=[contenthash]', |
rsbuild.config.js
Outdated
| }, | ||
| chunkFilename: `${process.env.npm_package_name}-[name].js?v=[contenthash]`, | ||
| assetModuleFilename: '[name][ext]', | ||
| publicPath: '/apps/workflow_ocr/js/', |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The publicPath is hardcoded to '/apps/workflow_ocr/js/' which tightly couples this configuration to the workflow_ocr app. The old configuration used 'auto' for publicPath, which would automatically determine the correct path. This hardcoded value will break if the app name changes or if the configuration is reused in a different context.
| publicPath: '/apps/workflow_ocr/js/', | |
| publicPath: 'auto', |
rsbuild.config.js
Outdated
| __IS_DESKTOP__: false, | ||
| __VUE_OPTIONS_API__: true, | ||
| __VUE_PROD_DEVTOOLS__: false, | ||
| __webpack_public_path__: '/apps/workflow_ocr/js/', |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The webpack_public_path is hardcoded to '/apps/workflow_ocr/js/' which creates the same coupling issue as the publicPath. This should be dynamic or configurable rather than hardcoded to a specific app name.
rsbuild.config.js
Outdated
| }, | ||
| }, | ||
| optimization: { | ||
| splitChunks: false, |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old configuration had sophisticated chunk splitting with cacheGroups configuration for vendor chunks. The new configuration disables splitChunks entirely with 'splitChunks: false'. This could negatively impact performance by preventing code splitting and vendor chunk optimization, potentially resulting in larger initial bundle sizes and reduced caching efficiency.
| splitChunks: false, | |
| splitChunks: { | |
| chunks: 'all', | |
| cacheGroups: { | |
| vendors: { | |
| test: /[\\/]node_modules[\\/]/, | |
| name: 'vendors', | |
| chunks: 'all', | |
| priority: -10, | |
| }, | |
| common: { | |
| minChunks: 2, | |
| name: 'common', | |
| chunks: 'all', | |
| priority: -20, | |
| }, | |
| }, | |
| }, |
- Updated package.json to replace rspack commands with rsbuild equivalents. - Removed rspack.config.js and added rsbuild.config.js with new configuration. - Adjusted linting scripts to ensure proper file matching. - Updated dependencies to align with rsbuild requirements.
96814d7 to
3b8fa83
Compare
|



