To configure the on-demand import of the component library, you can configure it through source.transformImport, which is equivalent to babel-plugin-import.
export default {
source: {
transformImport: [
{
libraryName: 'my-components',
libraryDirectory: 'es',
style: true,
},
],
},
};
For the sake of compilation performance, Rsbuild will not perform ESLint verification during the compilation process by default. If you require this feature, you can use Rsbuild's ESLint plugin.
To upload static assets such as JS and CSS to CDN for use, set the URL prefix of static assets through the output.assetPrefix configuration.
export default {
output: {
assetPrefix: 'https://cdn.example.com/assets/',
},
};
For the production build, we can remove the console
from the code, so as to avoid the log of the development mode being output to the production.
Rsbuild provides a configuration option to remove console by default, please see performance.removeConsole.
By using the Rsbuild debug mode, you can view the Rspack configuration generated by Rsbuild.
You can enable the debug mode of Rsbuild by adding the DEBUG=rsbuild
environment variable when performing the build. In this mode, the internally generated Rspack configuration will be outputted to the "dist" directory.
➜ DEBUG=rsbuild pnpm dev
...
rsbuild 10:00:00 configuration loaded from: /path/to/...
rsbuild 10:00:00 registering default plugins
rsbuild 10:00:00 default plugins registered
...
config inspection completed, generated files:
- Rsbuild config: /root/my-project/dist/.rsbuild/rsbuild.config.mjs
- Rspack config (web): /root/my-project/dist/.rsbuild/rspack.config.web.mjs
By default, Rsbuild will print all error and warning logs generated by the build process.
If a large number of warning logs are generated by a third-party package and you want to ignore them, specific warning logs can be ignored through the ignoreWarnings
configuration provided by Rspack.
export default {
tools: {
rspack: {
ignoreWarnings: [/Using \/ for division outside of calc()/],
},
},
};
For details, please refer to: ignoreWarnings.