@@ -280,7 +280,7 @@ pub struct OptimizationConfig {
280280 /// local names for variables, functions etc., which can be useful for
281281 /// debugging/profiling purposes.
282282 pub no_mangling : Option < bool > ,
283- pub minify : Option < bool > ,
283+ pub minify : Option < MinifyConfig > ,
284284 pub tree_shaking : Option < bool > ,
285285 pub package_imports : Option < Vec < RcStr > > ,
286286 pub modularize_imports : Option < FxIndexMap < String , ModularizeImportPackageConfig > > ,
@@ -691,6 +691,43 @@ pub struct OptionServerActions(Option<ServerActions>);
691691#[ turbo_tasks:: value( transparent) ]
692692pub struct ExternalsConfig ( FxIndexMap < RcStr , ExternalConfig > ) ;
693693
694+ #[ turbo_tasks:: value( transparent) ]
695+ pub struct MinifyConfigValue ( MinifyConfig ) ;
696+
697+ #[ derive(
698+ Clone , Debug , PartialEq , Eq , Serialize , Deserialize , TraceRawVcs , NonLocalValue , OperationValue ,
699+ ) ]
700+ #[ serde( untagged) ]
701+ pub enum MinifyConfig {
702+ Boolean ( bool ) ,
703+ Config {
704+ #[ serde( default ) ]
705+ extract_comments : bool ,
706+ } ,
707+ }
708+
709+ impl Default for MinifyConfig {
710+ fn default ( ) -> Self {
711+ MinifyConfig :: Boolean ( false )
712+ }
713+ }
714+
715+ impl MinifyConfig {
716+ pub fn is_enabled ( & self ) -> bool {
717+ match self {
718+ Self :: Boolean ( enabled) => * enabled,
719+ Self :: Config { .. } => true ,
720+ }
721+ }
722+
723+ pub fn extract_comments ( & self ) -> bool {
724+ match self {
725+ Self :: Boolean ( _) => false ,
726+ Self :: Config { extract_comments } => * extract_comments,
727+ }
728+ }
729+ }
730+
694731#[ turbo_tasks:: value_impl]
695732impl Config {
696733 #[ turbo_tasks:: function]
@@ -1135,13 +1172,26 @@ impl Config {
11351172 let minify = self
11361173 . optimization
11371174 . as_ref ( )
1138- . map ( |op| op. minify . is_none_or ( |minify| minify) ) ;
1175+ . and_then ( |op| op. minify . as_ref ( ) )
1176+ . map ( |minify| minify. is_enabled ( ) ) ;
11391177
11401178 Ok ( Vc :: cell (
11411179 minify. unwrap_or ( matches ! ( * mode. await ?, Mode :: Production ) ) ,
11421180 ) )
11431181 }
11441182
1183+ #[ turbo_tasks:: function]
1184+ pub fn minify_config ( & self ) -> Vc < MinifyConfigValue > {
1185+ let minify_config = self
1186+ . optimization
1187+ . as_ref ( )
1188+ . and_then ( |op| op. minify . as_ref ( ) )
1189+ . cloned ( )
1190+ . unwrap_or_default ( ) ;
1191+
1192+ MinifyConfigValue ( minify_config) . cell ( )
1193+ }
1194+
11451195 #[ turbo_tasks:: function]
11461196 pub fn no_mangling ( & self ) -> Vc < bool > {
11471197 Vc :: cell (
0 commit comments