Skip to content

Only inline @import files if none will be skipped #167

@ryanfitzer

Description

@ryanfitzer

The flattenCss function in optimize.js will skip imports that contain media queries with expressions:

@import url('somefile.css') screen and (min-width:768px)

This makes sense. The problem is that the function will still inline other imports that occur before ones that are skipped. These skipped @import rules become invalid and are ignored by browsers.

The W3C spec for CSS 2.1 states in section 4.1.5 At-rules:

CSS 2.1 user agents must ignore any @import rule that occurs inside a block or after any non-ignored statement other than an @charset or an @import rule.

flattenCss should first check if the file contains any imports that would be skipped before inlining imports.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions