@@ -112,6 +112,9 @@ export const pluginAssetsRetry = (
112112
113113 if ( inlineScript ) {
114114 api . modifyHTMLTags ( async ( { headTags, bodyTags } , { environment } ) => {
115+ if ( environment . config . output . target !== 'web' ) {
116+ return { headTags, bodyTags } ;
117+ }
115118 const { minify, crossorigin } = getDefaultValueFromRsbuildConfig (
116119 environment . config ,
117120 ) ;
@@ -131,6 +134,9 @@ export const pluginAssetsRetry = (
131134 } else {
132135 api . modifyHTMLTags (
133136 async ( { headTags, bodyTags } , { assetPrefix, environment } ) => {
137+ if ( environment . config . output . target !== 'web' ) {
138+ return { headTags, bodyTags } ;
139+ }
134140 const scriptPath = getScriptPath ( environment ) ;
135141 const url = ensureAssetPrefix ( scriptPath , assetPrefix ) ;
136142
@@ -149,10 +155,13 @@ export const pluginAssetsRetry = (
149155 api . processAssets (
150156 { stage : 'additional' } ,
151157 async ( { sources, compilation, environment } ) => {
158+ const { config } = environment ;
159+ if ( config . output . target !== 'web' ) {
160+ return ;
161+ }
152162 const scriptPath = getScriptPath ( environment ) ;
153- const { crossorigin, minify } = getDefaultValueFromRsbuildConfig (
154- environment . config ,
155- ) ;
163+ const { crossorigin, minify } =
164+ getDefaultValueFromRsbuildConfig ( config ) ;
156165 const runtimeOptions = getRuntimeOptions ( userOptions , crossorigin ) ;
157166 const code = await getRetryCode ( runtimeOptions , minify ) ;
158167 compilation . emitAsset ( scriptPath , new sources . RawSource ( code ) ) ;
@@ -161,9 +170,8 @@ export const pluginAssetsRetry = (
161170 }
162171
163172 api . modifyBundlerChain ( async ( chain , { environment } ) => {
164- const { config, htmlPaths } = environment ;
165-
166- if ( ! userOptions || Object . keys ( htmlPaths ) . length === 0 ) {
173+ const { config } = environment ;
174+ if ( config . output . target !== 'web' ) {
167175 return ;
168176 }
169177
0 commit comments