File tree 1 file changed +9
-2
lines changed
packages/vite/src/node/plugins
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -939,12 +939,19 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
939
939
`document.head.appendChild(${ style } );`
940
940
let injectionPoint
941
941
const wrapIdx = code . indexOf ( 'System.register' )
942
+ const singleQuoteUseStrict = `'use strict';`
943
+ const doubleQuoteUseStrict = `"use strict";`
942
944
if ( wrapIdx >= 0 ) {
943
945
const executeFnStart = code . indexOf ( 'execute:' , wrapIdx )
944
946
injectionPoint = code . indexOf ( '{' , executeFnStart ) + 1
947
+ } else if ( code . includes ( singleQuoteUseStrict ) ) {
948
+ injectionPoint =
949
+ code . indexOf ( singleQuoteUseStrict ) + singleQuoteUseStrict . length
950
+ } else if ( code . includes ( doubleQuoteUseStrict ) ) {
951
+ injectionPoint =
952
+ code . indexOf ( doubleQuoteUseStrict ) + doubleQuoteUseStrict . length
945
953
} else {
946
- const insertMark = "'use strict';"
947
- injectionPoint = code . indexOf ( insertMark ) + insertMark . length
954
+ throw new Error ( 'Injection point for inlined CSS not found' )
948
955
}
949
956
s ||= new MagicString ( code )
950
957
s . appendRight ( injectionPoint , injectCode )
You can’t perform that action at this time.
0 commit comments