@@ -20,10 +20,10 @@ import type Sass from 'sass'
2020import type Stylus from 'stylus'
2121import type Less from 'less'
2222import type { Alias } from 'dep-types/alias'
23- import type { LightningCSSOptions } from 'dep-types/lightningcss'
2423import type { TransformOptions } from 'esbuild'
2524import { formatMessages , transform } from 'esbuild'
2625import type { RawSourceMap } from '@ampproject/remapping'
26+ import type { BundleAsyncOptions , CustomAtRules } from 'lightningcss'
2727import { getCodeWithSourcemap , injectSourcesContent } from '../server/sourcemap'
2828import type { ModuleNode } from '../server/moduleGraph'
2929import type { ResolveFn , ViteDevServer } from '../'
@@ -139,6 +139,12 @@ export type ResolvedCSSOptions = Omit<CSSOptions, 'lightningcss'> & {
139139 }
140140}
141141
142+ // remove options set by Vite
143+ export type LightningCSSOptions = Omit <
144+ BundleAsyncOptions < CustomAtRules > ,
145+ 'filename' | 'resolver' | 'minify' | 'sourceMap' | 'analyzeDependencies'
146+ >
147+
142148export function resolveCSSOptions (
143149 options : CSSOptions | undefined ,
144150) : ResolvedCSSOptions | undefined {
@@ -2167,13 +2173,15 @@ async function compileLightningCSS(
21672173 ? ( await importLightningCSS ( ) ) . transformStyleAttribute ( {
21682174 filename,
21692175 code : Buffer . from ( src ) ,
2170- targets : config . css ?. lightningcss ?. targets ,
21712176 minify : config . isProduction && ! ! config . build . cssMinify ,
2177+ targets : config . css ?. lightningcss ?. targets ,
21722178 analyzeDependencies : true ,
2179+ visitor : config . css ?. lightningcss ?. visitor ,
21732180 } )
21742181 : await (
21752182 await importLightningCSS ( )
21762183 ) . bundleAsync ( {
2184+ ...config . css ?. lightningcss ,
21772185 filename,
21782186 resolver : {
21792187 read ( filePath ) {
@@ -2204,14 +2212,12 @@ async function compileLightningCSS(
22042212 return id
22052213 } ,
22062214 } ,
2207- targets : config . css ?. lightningcss ?. targets ,
22082215 minify : config . isProduction && ! ! config . build . cssMinify ,
22092216 sourceMap : config . css ?. devSourcemap ,
22102217 analyzeDependencies : true ,
22112218 cssModules : cssModuleRE . test ( id )
22122219 ? config . css ?. lightningcss ?. cssModules ?? true
22132220 : undefined ,
2214- drafts : config . css ?. lightningcss ?. drafts ,
22152221 } )
22162222
22172223 let css = res . code . toString ( )
0 commit comments