webpack2 vue-cli autoprefixer not work in js file

2019-09-15 03:05发布

问题:

I use vue-cli, which depends on webpack2. I know vue-loader can compile .vue file, it can compile scss&autoprefixer successfully in .vue file, but when I use require .scss file in a js file, autoprefixer does not work, how can i solve it?

I have try this(vue-loader.conf.js) but it does not work:

module.exports = {
  loaders: utils.cssLoaders({
    sourceMap: isProduction
      ? config.build.productionSourceMap
      : config.dev.cssSourceMap,
    extract: isProduction
  }),
  postcss: [
    require('autoprefixer')({
      browsers: ['last 7 versions']
    })
  ]
}