source.assetsInclude

Include additional files that should be treated as static assets.

By default, Rsbuild treats common image, font, audio, and video files as static assets. Through the source.assetsInclude config, you can specify additional file types that should be treated as static assets. These added static assets are processed using the same rules as the built-in supported static assets, see Static Assets.

The value of source.assetsInclude is the same as the test option in Rspack loader. It can be a regular expression, string, array, logical condition, etc. For more details, see Rspack RuleSetCondition.

Example

  • Treating .json5 files as static assets:
export default defineConfig({
  source: {
    assetsInclude: /\.json5$/,
  },
});
  • Treating multiple file types as static assets:
export default defineConfig({
  source: {
    assetsInclude: [/\.json5$/, /\.pdf$/],
  },
});
  • Treating specific files as static assets:
import path from 'node:path';

export default defineConfig({
  source: {
    assetsInclude: path.resolve(__dirname, 'src/assets/foo.json5'),
  },
});
ON THIS PAGE