Skip to content

ng serve breaks when using @import in index.html #28147

Open
@ricardochl

Description

@ricardochl

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

17.3.4

Description

I'm encountering an issue where ng serve fails to build and serve my Angular application when I use the @import directive in the index.html file. This behavior is unexpected as the @import rule is a standard CSS mechanism.

Minimal Reproduction

  1. Create a new project with ng new (using Sass (SCSS))
  2. Add the following piece of code to the head tag in the index.html file
  <style>
    @import url('./styles.css');
  </style>
  1. Run ng serve

Exception or Error

Unable to resolve `@import "./styles.css"` from `my-path`
[vite] Internal server error: [postcss] ENOENT: no such file or directory, open './styles.css'
Plugin: vite:css
File: /index.html?html-proxy&direct&index=0.css:undefined:NaN

Your Environment

Angular CLI: 18.1.3
Node: 20.11.1
Package Manager: npm 10.2.4
OS: darwin arm64

Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1801.3 (cli-only)
@angular-devkit/core         18.1.3 (cli-only)
@angular-devkit/schematics   18.1.3 (cli-only)
@schematics/angular          18.1.3 (cli-only)

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions