Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: @import must precede all other statements (besides @charset)

I am working on angular app and while run the app it's not showing any errors but I'm getting this kind of warning's in many css files.

Module Warning (from ./node_modules/postcss-loader/src/index.js):
Warning

 (114:1) @import must precede all other statements (besides @charset)

What I have imported on 114 line is this.

@import url(http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);

Where ever I have imported like this in all that css showing this kind of warnings.

Is there any solution for this?

like image 207
sohil vaghasiya Avatar asked Sep 19 '19 05:09

sohil vaghasiya


People also ask

What happens if the import conditions do not match?

If the import conditions do not match, the rules in the imported stylesheet do not apply. Is the name of a cascade layer into which the contents of the linked resource are imported. Imported rules must come before all other types of rules, except @charset rules. The @import rule is not a nested statement.

Can @import be used inside conditional group at-rules?

The @import rule is not a nested statement. Therefore, it cannot be used inside conditional group at-rules. So that user agents can avoid retrieving resources for unsupported media types, authors may specify media-dependent import conditions. These conditional imports specify comma-separated media queries after the URL.

Why are my Imports not at the top in this plugin?

This plugin attempts to follow the CSS @import spec; @import statements must precede all other statements (besides @charset ). Since your imports are not at the top, you're going to get an error.

How do I import a custom style rule into a cascade?

Rules can also be imported into an existing cascade layer. The layer keyword or the layer () function is used with @import for this purpose. Declarations in style rules from imported stylesheets interact with the cascade as if they were written literally into the stylesheet at the point of the import.


2 Answers

I want to explain it through two screenshots that why it is giving warning. Because you are not using @import ....line at first line. See this screenshot it is giving warning. enter image description here

see below screenshot this is the solution:

Warning has gone because I have used @import ... line at first line in styles.css file.

enter image description here

like image 123
Chaman Bharti Avatar answered Oct 19 '22 00:10

Chaman Bharti


Your css loader plugin attempts to follow the @import where its not at the top of (first lines of) the css file. @import statements must precede all other statements (besides @charset).

like image 2
Amirhossein Mehrvarzi Avatar answered Oct 19 '22 01:10

Amirhossein Mehrvarzi