File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
packages/vite/src/node/plugins Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -880,12 +880,21 @@ export function cssPostPlugin(config: ResolvedConfig): RolldownPlugin {
880
880
`document.head.appendChild(${ style } );`
881
881
let injectionPoint
882
882
const wrapIdx = code . indexOf ( 'System.register' )
883
+ const singleQuotesUseStruct = `'use strict';`
884
+ const doubleQuotesUseStruct = `"use strict";`
883
885
if ( wrapIdx >= 0 ) {
884
886
const executeFnStart = code . indexOf ( 'execute:' , wrapIdx )
885
887
injectionPoint = code . indexOf ( '{' , executeFnStart ) + 1
888
+ } else if ( code . includes ( singleQuotesUseStruct ) ) {
889
+ injectionPoint =
890
+ code . indexOf ( singleQuotesUseStruct ) +
891
+ singleQuotesUseStruct . length
892
+ } else if ( code . includes ( doubleQuotesUseStruct ) ) {
893
+ injectionPoint =
894
+ code . indexOf ( doubleQuotesUseStruct ) +
895
+ doubleQuotesUseStruct . length
886
896
} else {
887
- const insertMark = "'use strict';"
888
- injectionPoint = code . indexOf ( insertMark ) + insertMark . length
897
+ throw new Error ( 'Not found injection point for inlined CSS' )
889
898
}
890
899
s ||= new MagicString ( code )
891
900
s . appendRight ( injectionPoint , injectCode )
You can’t perform that action at this time.
0 commit comments