File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
packages/vite/src/node/plugins Expand file tree Collapse file tree 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 {
939939 `document.head.appendChild(${ style } );`
940940 let injectionPoint
941941 const wrapIdx = code . indexOf ( 'System.register' )
942+ const singleQuoteUseStrict = `'use strict';`
943+ const doubleQuoteUseStrict = `"use strict";`
942944 if ( wrapIdx >= 0 ) {
943945 const executeFnStart = code . indexOf ( 'execute:' , wrapIdx )
944946 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
945953 } else {
946- const insertMark = "'use strict';"
947- injectionPoint = code . indexOf ( insertMark ) + insertMark . length
954+ throw new Error ( 'Injection point for inlined CSS not found' )
948955 }
949956 s ||= new MagicString ( code )
950957 s . appendRight ( injectionPoint , injectCode )
You can’t perform that action at this time.
0 commit comments