Skip to content

Add a vue-cli Configure Sass-Resources-Loader Example #1019

@vaxilicaihouxian

Description

@vaxilicaihouxian

What problem does this feature solve?

I read the vue-cli docs about sass-resources-loader section and can not understand how to configure the vue-cli project for this.
After some codes reading,I write these codes for that loader to work out:

//vue.config.js
var path = require('path');
module.exports = {
    chainWebpack: config => {
        config.module
            .rule('vue')
            .use('vue-loader')
            .tap(options => {
                var scssResourceLoader = {
                    loader: 'sass-resources-loader',
                    options: {
                        resources: path.resolve(__dirname, 'src/assets/_variables.scss')
                    }
                };
                options.loaders.scss.push(scssResourceLoader);
                return options;
            });
    }
}

I hope this will help others.

What does the proposed API look like?

...

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