@@ -280,7 +280,7 @@ pub struct OptimizationConfig {
280
280
/// local names for variables, functions etc., which can be useful for
281
281
/// debugging/profiling purposes.
282
282
pub no_mangling : Option < bool > ,
283
- pub minify : Option < bool > ,
283
+ pub minify : Option < MinifyConfig > ,
284
284
pub tree_shaking : Option < bool > ,
285
285
pub package_imports : Option < Vec < RcStr > > ,
286
286
pub modularize_imports : Option < FxIndexMap < String , ModularizeImportPackageConfig > > ,
@@ -691,6 +691,43 @@ pub struct OptionServerActions(Option<ServerActions>);
691
691
#[ turbo_tasks:: value( transparent) ]
692
692
pub struct ExternalsConfig ( FxIndexMap < RcStr , ExternalConfig > ) ;
693
693
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
+
694
731
#[ turbo_tasks:: value_impl]
695
732
impl Config {
696
733
#[ turbo_tasks:: function]
@@ -1135,13 +1172,26 @@ impl Config {
1135
1172
let minify = self
1136
1173
. optimization
1137
1174
. 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 ( ) ) ;
1139
1177
1140
1178
Ok ( Vc :: cell (
1141
1179
minify. unwrap_or ( matches ! ( * mode. await ?, Mode :: Production ) ) ,
1142
1180
) )
1143
1181
}
1144
1182
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
+
1145
1195
#[ turbo_tasks:: function]
1146
1196
pub fn no_mangling ( & self ) -> Vc < bool > {
1147
1197
Vc :: cell (
0 commit comments