File tree Expand file tree Collapse file tree 4 files changed +40
-2
lines changed
test/e2e/css-data-url-global-pages Expand file tree Collapse file tree 4 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -846,9 +846,12 @@ async fn validate_pages_css_imports_individual(
846846 candidates
847847 . into_iter ( )
848848 . map ( async |issue| {
849+ let path = issue. module . ident ( ) . path ( ) . await ?;
849850 // We allow imports of global CSS files which are inside of `node_modules`.
851+ // We also allow data URL CSS imports (e.g. `data:text/css,...`) since they
852+ // are mostly tooling-generated and co-located with the importing components
850853 Ok (
851- if !issue . module . ident ( ) . path ( ) . await ? . is_in_node_modules ( ) {
854+ if !path . is_in_node_modules ( ) && ! path. file_name ( ) . starts_with ( "data:" ) {
852855 Some ( issue)
853856 } else {
854857 None
@@ -868,8 +871,9 @@ async fn validate_pages_css_imports_individual(
868871/// Validates that the global CSS/SCSS/SASS imports are only valid imports with the following
869872/// rules:
870873/// * The import is made from a `node_modules` package
874+ /// * The imported CSS is a `data:` URL module
871875/// * The import is made from a `.module.css` file
872- /// * The import is made from the `pages/_app.js`, or equivalent file.
876+ /// * The import is made from the `pages/_app.js`, or equivalent file
873877#[ turbo_tasks:: function]
874878pub async fn validate_pages_css_imports (
875879 graph : Vc < ModuleGraph > ,
Original file line number Diff line number Diff line change 1+ import { nextTestSetup } from 'e2e-utils'
2+
3+ // CSS data urls are only supported in Turbopack
4+ ; ( process . env . IS_TURBOPACK_TEST ? describe : describe . skip ) (
5+ 'css-data-url-global-pages' ,
6+ ( ) => {
7+ const { next } = nextTestSetup ( {
8+ files : __dirname ,
9+ } )
10+
11+ it ( 'should apply styles from data url correctly' , async ( ) => {
12+ const browser = await next . browser ( '/' )
13+
14+ const fontWeight = await browser
15+ . elementByCss ( '#styled' )
16+ . getComputedCss ( 'font-weight' )
17+
18+ expect ( fontWeight ) . toBe ( '700' )
19+ } )
20+ }
21+ )
Original file line number Diff line number Diff line change 1+ import type { NextConfig } from 'next'
2+
3+ const nextConfig : NextConfig = {
4+ /* config options here */
5+ }
6+
7+ export default nextConfig
Original file line number Diff line number Diff line change 1+ // @ts -expect-error
2+ import 'data:text/css,#styled{font-weight:700}'
3+
4+ export default function Home ( ) {
5+ return < div id = "styled" > This text should be bold</ div >
6+ }
You can’t perform that action at this time.
0 commit comments