Skip to content

@ alias doesn't resolve correctly in style tag in .vue files #6356

@thezealousfool

Description

@thezealousfool

What problem does this feature solve?

In webpack.base.config the @ alias is defined as:

...
resolve: {
    extensions: ['.js', '.vue', '.json'],
    alias: {
         'vue$': 'vue/dist/vue.esm.js',
         '@': resolve(src)
    }
},
...

But when I use the @ alias in a style tag in a .vue file it doesn't seem to work.

<style lang="scss" scoped>
    @import "@/styles/variables";
    ...
</style>

I get the error
File to import not found or unreadable: @/styles/variables.

PS: I am using a src/styles/_variables.scss file to store sass variables which I am importing in every .vue file. I would love to know if there is some other way of importing the variables file in every component using sass-loader or style-loader.

Thanks

What does the proposed API look like?

<style lang="scss" scoped>
    @import "@/styles/variables";
    ...
</style>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions