@@ -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 {
0 commit comments