@@ -438,35 +438,6 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
438
438
str ( ) . remove ( end + 1 , expEnd )
439
439
}
440
440
441
- if (
442
- ! isDynamicImport &&
443
- specifier &&
444
- ! specifier . includes ( '?' ) && // ignore custom queries
445
- isCSSRequest ( specifier ) &&
446
- ! isModuleCSSRequest ( specifier )
447
- ) {
448
- const sourceExp = source . slice ( expStart , start )
449
- if (
450
- sourceExp . includes ( 'from' ) && // check default and named imports
451
- ! sourceExp . includes ( '__vite_glob_' ) // glob handles deprecation message itself
452
- ) {
453
- const newImport =
454
- sourceExp + specifier + `?inline` + source . slice ( end , expEnd )
455
- this . warn (
456
- `\n` +
457
- colors . cyan ( importerModule . file ) +
458
- `\n` +
459
- colors . reset ( generateCodeFrame ( source , start ) ) +
460
- `\n` +
461
- colors . yellow (
462
- `Default and named imports from CSS files are deprecated. ` +
463
- `Use the ?inline query instead. ` +
464
- `For example: ${ newImport } ` ,
465
- ) ,
466
- )
467
- }
468
- }
469
-
470
441
// static import or valid string in dynamic import
471
442
// If resolvable, let's resolve it
472
443
if ( specifier ) {
@@ -509,6 +480,35 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
509
480
// normalize
510
481
const [ url , resolvedId ] = await normalizeUrl ( specifier , start )
511
482
483
+ if (
484
+ ! isDynamicImport &&
485
+ specifier &&
486
+ ! specifier . includes ( '?' ) && // ignore custom queries
487
+ isCSSRequest ( resolvedId ) &&
488
+ ! isModuleCSSRequest ( resolvedId )
489
+ ) {
490
+ const sourceExp = source . slice ( expStart , start )
491
+ if (
492
+ sourceExp . includes ( 'from' ) && // check default and named imports
493
+ ! sourceExp . includes ( '__vite_glob_' ) // glob handles deprecation message itself
494
+ ) {
495
+ const newImport =
496
+ sourceExp + specifier + `?inline` + source . slice ( end , expEnd )
497
+ this . warn (
498
+ `\n` +
499
+ colors . cyan ( importerModule . file ) +
500
+ `\n` +
501
+ colors . reset ( generateCodeFrame ( source , start ) ) +
502
+ `\n` +
503
+ colors . yellow (
504
+ `Default and named imports from CSS files are deprecated. ` +
505
+ `Use the ?inline query instead. ` +
506
+ `For example: ${ newImport } ` ,
507
+ ) ,
508
+ )
509
+ }
510
+ }
511
+
512
512
// record as safe modules
513
513
server ?. moduleGraph . safeModulesPath . add ( fsPathFromUrl ( url ) )
514
514
0 commit comments