Webpack postcss前缀在vue-cli 3中

问题描述 投票:0回答:1

我需要使用webpack为Bulma css类添加前缀。我找到了一个示例,但我的应用程序使用Vue CLI 3,我不知道如何将webpack配置转换为vue.config.js。

This is the webpack config

在我的vue.config.js中,我有以下内容:

  chainWebpack: config => {
    config.module
      .rule('css-prefixer')
      .use(['style-loader', 'css-loader'])
      .loader('postcss-loader')
      .tap(options => {
        // Prefixer goes here
        return options
      })
  }

这给出了一些内部webpack错误。

javascript vue.js webpack vue-cli-3 postcss-loader
1个回答
0
投票

只需设法在我的vue.config.js中执行此操作

const path = require('path')
const prefixer = require('postcss-prefixer')

module.exports = {
  css: {
    loaderOptions: {
      postcss: {
        plugins: [
          prefixer({
            prefix: 'b-'
          })
        ]
      }
    }
  }
}

© www.soinside.com 2019 - 2024. All rights reserved.