@@ -3,7 +3,7 @@ use next_custom_transforms::transforms::strip_page_exports::ExportFilter;
3
3
use turbo_rcstr:: RcStr ;
4
4
use turbo_tasks:: { ResolvedVc , Vc } ;
5
5
use turbopack:: module_options:: { ModuleRule , ModuleRuleEffect , RuleCondition } ;
6
- use turbopack_core:: reference_type:: { ReferenceType , UrlReferenceSubType } ;
6
+ use turbopack_core:: reference_type:: { CssReferenceSubType , ReferenceType , UrlReferenceSubType } ;
7
7
8
8
use crate :: {
9
9
mode:: NextMode ,
@@ -21,7 +21,7 @@ use crate::{
21
21
next_page_static_info:: get_next_page_static_info_assert_rule,
22
22
next_pure:: get_next_pure_rule, server_actions:: ActionsTransform ,
23
23
} ,
24
- util:: NextRuntime ,
24
+ util:: { NextRuntime , module_styles_rule_condition , styles_rule_condition } ,
25
25
} ;
26
26
27
27
/// Returns a list of module rules which apply server-side, Next.js-specific
@@ -51,35 +51,18 @@ pub async fn get_next_server_transforms_rules(
51
51
52
52
if !matches ! ( context_ty, ServerContextType :: AppRSC { .. } ) {
53
53
rules. extend ( [
54
- // Ignore the internal ModuleCssAsset -> CssModuleAsset references
55
- // The CSS Module module itself is still needed for class names
56
- ModuleRule :: new_internal (
57
- RuleCondition :: any ( vec ! [
58
- RuleCondition :: ResourcePathEndsWith ( ".module.css" . into( ) ) ,
59
- RuleCondition :: ContentTypeStartsWith ( "text/css+module" . into( ) ) ,
60
- ] ) ,
61
- vec ! [ ModuleRuleEffect :: Ignore ] ,
62
- ) ,
63
- ] ) ;
64
- rules. extend ( [
65
- // Ignore all non-module CSS references
54
+ // Ignore the inner ModuleCssAsset -> CssModuleAsset references
55
+ // The CSS Module module itself (and the Analyze reference) is still needed to generate
56
+ // the class names object.
66
57
ModuleRule :: new (
67
- RuleCondition :: any ( vec ! [
68
- RuleCondition :: all( vec![
69
- RuleCondition :: ResourcePathEndsWith ( ".css" . into( ) ) ,
70
- RuleCondition :: not( RuleCondition :: ResourcePathEndsWith (
71
- ".module.css" . into( ) ,
72
- ) ) ,
73
- ] ) ,
74
- RuleCondition :: all( vec![
75
- RuleCondition :: ContentTypeStartsWith ( "text/css" . into( ) ) ,
76
- RuleCondition :: not( RuleCondition :: ContentTypeStartsWith (
77
- "text/css+module" . into( ) ,
78
- ) ) ,
79
- ] ) ,
58
+ RuleCondition :: all ( vec ! [
59
+ RuleCondition :: ReferenceType ( ReferenceType :: Css ( CssReferenceSubType :: Inner ) ) ,
60
+ module_styles_rule_condition( ) ,
80
61
] ) ,
81
62
vec ! [ ModuleRuleEffect :: Ignore ] ,
82
63
) ,
64
+ // Ignore all non-module CSS references
65
+ ModuleRule :: new ( styles_rule_condition ( ) , vec ! [ ModuleRuleEffect :: Ignore ] ) ,
83
66
] ) ;
84
67
}
85
68
0 commit comments