File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -48,9 +48,9 @@ function injectionCSSCodePlugin(cssToInject: string, styleId?: string): Plugin {
4848 if ( id == cssInjectedByJsId ) {
4949 const cssCode = JSON . stringify ( cssToInject . trim ( ) ) ;
5050
51- return `try{var elementStyle = document.createElement('style');${
51+ return `try{if (typeof document !== 'undefined'){ var elementStyle = document.createElement('style');${
5252 typeof styleId == 'string' && styleId . length > 0 ? `elementStyle.id = '${ styleId } ';` : ''
53- } elementStyle.appendChild(document.createTextNode(${ cssCode } ));document.head.appendChild(elementStyle);}catch(e){console.error('vite-plugin-css-injected-by-js', e);}`;
53+ } elementStyle.appendChild(document.createTextNode(${ cssCode } ));document.head.appendChild(elementStyle);}} catch(e){console.error('vite-plugin-css-injected-by-js', e);}`;
5454 }
5555 } ,
5656 } ;
You can’t perform that action at this time.
0 commit comments