Vue-loader: imported .css file in sass isn't under scope

Created on 19 Feb 2017  路  2Comments  路  Source: vuejs/vue-loader

When I @import a .css file in .vue scoped sass as below:

<template>
<div id="test"></div>
</template>

<style lang="scss" scoped>
  @import "foo.css";
</style>

foo.css content

#test {
    color: red;
}

the #test style is not just applied under the component scope.

image

But, if I change foo.css to sass file foo.scss, the scoped css will work.

image

Most helpful comment

For anyone else having this issue just change the file and import name to *.scss

All 2 comments

Importing a plain .css in SCSS results in a raw URL import instead of inlining the target file into the current file. There's no way for vue-loader to process an URL import.

For anyone else having this issue just change the file and import name to *.scss

Was this page helpful?
0 / 5 - 0 ratings