Replies: 1 comment 1 reply
-
|
Rsbuild does not provide a config option to do this, but you can remove the JS files by adding a tiny Rspack plugin. Example: // rsbuild.config.ts
import { defineConfig } from '@rsbuild/core';
class RemoveJsPlugin {
apply(compiler) {
compiler.hooks.compilation.tap('RemoveJsPlugin', (compilation) => {
compilation.hooks.processAssets.tap(
{
name: 'RemoveJsPlugin',
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
},
() => {
for (const name of Object.keys(compilation.assets)) {
if (name.endsWith('.js')) {
compilation.deleteAsset(name);
}
}
},
);
});
}
}
export default defineConfig({
source: {
entry: {
style: './src/style.css',
},
},
tools: {
rspack: {
plugins: [new RemoveJsPlugin()],
},
},
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a small project with no
jsfiles.But I'd like to use rsbuild for the
cssfiles.How can I rsbuild
cssfiles withoutjsfiles?I set the entry like this:
But there is still a
style.jsgenerated.Besides that, the small images I imported in
cssfiles are also exported to thisjsfile.That mean there are duplicated base64 data for the same image in
cssfile andjsfile.Beta Was this translation helpful? Give feedback.
All reactions