File tree 1 file changed +8
-3
lines changed 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import webpack from 'webpack';
11
11
import { fileURLToPath } from 'node:url' ;
12
12
import { readFileSync } from 'node:fs' ;
13
13
import { env } from 'node:process' ;
14
- import { LightningCssMinifyPlugin } from 'lightningcss-loader' ;
15
14
16
15
const { EsbuildPlugin} = EsBuildLoader ;
17
16
const { SourceMapDevToolPlugin, DefinePlugin} = webpack ;
@@ -52,6 +51,12 @@ const filterCssImport = (url, ...args) => {
52
51
return true ;
53
52
} ;
54
53
54
+ // in case lightningcss fails to load, fall back to esbuild for css minify
55
+ let LightningCssMinifyPlugin ;
56
+ try {
57
+ ( { LightningCssMinifyPlugin} = await import ( 'lightningcss-loader' ) ) ;
58
+ } catch { }
59
+
55
60
/** @type {import("webpack").Configuration } */
56
61
export default {
57
62
mode : isProduction ? 'production' : 'development' ,
@@ -97,10 +102,10 @@ export default {
97
102
new EsbuildPlugin ( {
98
103
target : 'es2015' ,
99
104
minify : true ,
100
- css : false ,
105
+ css : ! LightningCssMinifyPlugin ,
101
106
legalComments : 'none' ,
102
107
} ) ,
103
- new LightningCssMinifyPlugin ( ) ,
108
+ LightningCssMinifyPlugin && new LightningCssMinifyPlugin ( ) ,
104
109
] ,
105
110
splitChunks : {
106
111
chunks : 'async' ,
You can’t perform that action at this time.
0 commit comments