laravel-mix: Laravel-Mix 4.0.2 breaks /deep/ in Vue component styling
- Laravel Mix Version: 4.0.2 (
npm list --depth=0) - Node Version (
node -v): 11.3 - NPM Version (
npm -v): 6.5 - OS: MacOS Mojave
Description:
I have a Vue component where I need scoped styling to affect a child component. I use /deep/ for this. This has always worked pre Laravel-Mix 4.
<style lang="scss" scoped>
/deep/ .some-styling {
}
With Laravel-Mix 4, I get the following error on npm run dev:
}
^
Expected selector.
& /deep/ .some-foo-styling{
^
or
.some-other-styling {
^
Expected selector.
/deep/.some-styling{
^
It seems clear that Mix no longer understands what /deep/ is, so I tried replacing it with the thing that it’s an alias for: >>>
Mix now compiles without error, but sadly the generated CSS is wrong. It should be:
[data-v-507877ae] .some-styling {
}
but instead it generates:
> .some-styling[data-v-507877ae] {
}
which means that the class must now be a direct descendant, so my styling breaks.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 17
Yes,
/deep/and>>>used to be part of SCSS/SASS, so they’re valid when parsed usingnode-sassfor now. The Vue loader then gives them special meaning when you use them inside a scoped component. Ifnode-sassremoves/deep/and>>>in the future and it’s no longer valid SCSS innode-sasstoo, then I guess Vue has to invent something else. The problem is that the style is parsed before the Vue loader processes it, so whatever they invent should be added tonode-sassanddart-sasstoo.This issue has been reported to Vue a while ago, but they’re not taking any action. If everyone’s code breaks some day they’ll probably act fast though. That’s how it usually works 😉
Ah yep, that’s the issue. If calling
mix.sass(), it always specifiessassas a required dependency, even if you’ve manually pulled innode-sass. So once the Vue component has to determine which Sass implementation to use, it sees thatsassis installed, and assumes that’s the one you want. Fixing now.Hmm, I tried again with Laravel Mix 4.0.4 to only have
node-sassinstalled as a dev dependency, and usingand then running
npm run devand it does automatically installsassas a dependency. Laravel-Mix as of version 4 should only installsassif it uses it, right? So either it does use it somewhere, or maybe it installs it by mistake.Using node-saas only withouth saas on the dependencies solved this for me