Adapting RSPack config
Overview
Sometimes there are cases where the default configuration doesn't suffice and special requirements arise. For this special case we support with hooking directly into the build config of rspack.
info
For how the extension mechanism works internally (merge order, params, per-target exports), see Extending Rspack Configuration in the Architecture section.
Config
- create a file like
rspack.extend.config.tsthe name doesn't realy matter - configure in
archibald.jsonunder theextendConfigproperty this name (relative to the root directory) - adapt the config accordingly
Example rspack.extend.config.ts:
import { defineExtendConfig } from '@archibald/cli/build';
// adapts the client build
export const client = defineExtendConfig(({ params, config }) => {
const contenthash = params.isServe ? '' : '.[contenthash]';
const path = params.isServe ? 'http://localhost:3101/public/' : '/public/';
config.module.rules = [
...config.module.rules,
{
test: /\.(mp4)$/,
use: [
{
loader: require.resolve('file-loader'),
options: {
publicPath: path,
name: `[name]${contenthash}.[ext]`
}
}
]
}
];
return config;
});
// adapts the server build
export const node = defineExtendConfig(({ params, config }) => {
// adapt config to your need
config.context = './src';
return config
});
// adapts both client and server builds
export default defineExtendConfig(({ params, config }) => {
// adapt config to your need
config.context = './src';
return config
});