Skip to content

Commit 25b7247

Browse files
committed
chore: update
1 parent 45848b2 commit 25b7247

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

packages/core/src/asset/assetConfig.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,35 @@ const pluginLibAsset = ({ bundle }: { bundle: boolean }): RsbuildPlugin => ({
1010
pre: [RSBUILD_SVGR_PLUGIN_NAME],
1111
setup(api) {
1212
api.modifyBundlerChain((config, { CHAIN_ID }) => {
13-
// only support transform the svg asset to mixedImport svgr file
14-
// remove issuer to make every svg asset is transformed
1513
const isUsingSvgr = Boolean(
1614
config.module
1715
.rule(CHAIN_ID.RULE.SVG)
1816
.oneOf(CHAIN_ID.RULE.SVG)
1917
.uses.has(CHAIN_ID.USE.SVGR),
2018
);
21-
if (isUsingSvgr) {
19+
if (isUsingSvgr && !bundle) {
20+
// in bundleless, only support transform the svg asset to mixedImport svgr file
21+
// remove issuer to make every svg asset is transformed
2222
const rule = config.module
2323
.rule(CHAIN_ID.RULE.SVG)
24-
.oneOf(CHAIN_ID.RULE.SVG);
24+
.oneOf(CHAIN_ID.ONE_OF.SVG);
2525
rule.issuer([]);
2626
}
2727
config
2828
.plugin(LibAssetExtractPlugin.name)
2929
.use(LibAssetExtractPlugin, [{ bundle, isUsingSvgr }]);
30+
31+
config.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT).tap((options) => {
32+
if (bundle) {
33+
return [
34+
{
35+
...options[0],
36+
enforceRelative: true,
37+
},
38+
];
39+
}
40+
return options;
41+
});
3042
});
3143
},
3244
});
@@ -43,13 +55,7 @@ export const composeAssetConfig = (
4355
dataUriLimit: 0, // default: no inline asset
4456
assetPrefix: 'auto',
4557
},
46-
tools: {
47-
rspack: {
48-
plugins: [
49-
new LibAssetExtractPlugin({ bundle: true, isUsingSvgr: false }),
50-
],
51-
},
52-
},
58+
plugins: [pluginLibAsset({ bundle: false })],
5359
};
5460
}
5561
return {

tests/integration/asset/index.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ test('set the assets output path', async () => {
137137
test('set the assets public path', async () => {
138138
const fixturePath = join(__dirname, 'public-path');
139139
const { contents } = await buildAndGetResults({ fixturePath });
140-
141140
// umd should preserve '__webpack_require__.p'
142141
const { content: indexUmdJs } = queryContent(contents.umd!, /index\.js/);
143142

0 commit comments

Comments
 (0)