Laravel-mix: Sass content order when import CSS

Created on 3 Jan 2021  路  8Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 6.0.6
  • Node Version: 15.5.0
  • NPM Version: 6.14.0
  • OS: MacOs 11.1

Description:

I'm coming from Gulp and I discover it's possible to import CSS file directly in Sass with Laravel Mix (not possible with Sass by default). But The issue is that source order are not maintained.

Example:

@import "base";

@import "button";
@import "baguettebox.js/dist/baguetteBox.min.css";

The compiled CSS files import CSS files before Sass import.
In this example bagettebox will be present before base and button.
Is there a workaround to fix that?

bug

All 8 comments

Confirmed with a small test case. I'm not sure if this is a Mix problem or a sass-loader/css-loader problem.

I've opened a bug in the sass-loader repo: https://github.com/webpack-contrib/sass-loader/issues/911

@thecrypticace thank you.

Hey, @florianbouvot, wanted to update you on this. This is appears to be a sass bug. I'll be attempting to track it down to file an issue there this weekend.

Thank a lot @thecrypticace.

Thinking again,
1 - Sass can't include CSS so they use CSS import at beginning of file.
2 - CSS loader include the CSS

So it's a specificity of how webpack works.
It doesn't work same on Gulp for example: I copy and rename *.css file to *.sass to a vendor folder and then I import it in my main Sass file.

Sass can't include CSS so they import it at the beginning which is the problem here. They shouldn't be moving the import.

It sounds like there's nothing we can do specifically on the Mix end to solve this, so I'll go ahead and close it.

@JeffreyWay thanks for your time and work ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Cheddam picture Cheddam  路  3Comments

rderimay picture rderimay  路  3Comments

Micaso picture Micaso  路  3Comments

mstralka picture mstralka  路  3Comments

hasnatbabur picture hasnatbabur  路  3Comments