yibn2008 / fast-sass-loader

High performance sass loader for webpack
250 stars 38 forks source link

How to use in vue-cli 3.x or webpack-chain #50

Closed PolanZ closed 5 years ago

PolanZ commented 5 years ago

vue.config.js

module.exports = {
  chainWebpack: config => {
    config.module
      .rule('.scss')
      .use('fast-sass-loader')
      .loader('fast-sass-loader')
      .tap(options => {
        return options
      })
  }
}

It's error.

hs-moosa commented 5 years ago

This is my config and it's working


  chainWebpack: (config) => {
    config.module.rules.delete('scss')

    let scssRule = config.module.rule('scss')
      .test(/\.scss$/);

    [
      { name: 'vue-style-loader' },
      { name: 'css-loader' },
      { name: 'postcss-loader' },
      { name: 'fast-sass-loader'}
    ].forEach((load) => {
      scssRule
        .use(load.name)
        .loader(load.loader || load.name)
        .options(load.options || {})
    })
  },
yibn2008 commented 5 years ago

I suggest you ask for help from webpack-chain, there is nothing special between fast-sass-loader and other webpack loader

towry commented 2 years ago

Searched around and tried many things still do not know how to use it in vue-cli project. :(

I used hs-moosa's solution, and use vue inspect to see the final config file, found out sass-loader is still in use with the vue-loader etc.

PolanZ commented 2 years ago

您的邮件我已收到,会尽快回复。亲