Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.8k views
in Technique[技术] by (71.8m points)

vue-cli3如何使用postcss-loader配置css使用BEM写法?

如果使得下面写法生效

bem写法
<template>
    <div class="ga-home__container">
        ...
    </div>
</template>

<style>
@component-namespace ga {
  @b home {
    @e container {
      width: 100%;
      height: 100%;
      color: #a2eeff;
    }
  }
}
</style>

使用postcss-salad配置后,需要可以渲染成功,但会报错:

postcss-custom-properties: variable '--bg-color' is undefined and used without a fallback

然后,再引入插件postcss-importpostcss-cssnext,但还是不行,而且会导致项目运行变得比较卡;


如下遇到的报错问题【与上面没关联】:

Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
Error: true is not a PostCSS plugin
Module build failed (from ./node_modules/postcss-loader/src/index.js):
TypeError: child.moveAfter is not a function
Module build failed (from ./node_modules/postcss-loader/index.js):
TypeError: Cannot read property 'postcss' of undefined


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

目前使用BEM没什么问题,但有些细节上还是无法进行处理,如果解决后期再进行更新;

可以查看文章:《vue-cli3配置postcss-loader使用BEM

文章下方还有没处理有问题,如果有知道怎么解决的,可在下方给出解决方法。[抱拳]


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...