空样式(.css/.scss)文件 [英] Empty style (.css/.scss) files
问题描述
当我创建Angular应用程序时,我正在使用CLI生成组件.经过一段时间的开发应用程序,我为每个组件都有样式文件,但它们的大部分都是空的.
When I create Angular application, I am using CLI for generating components. After certain time of developing app I have style file for every component but major part of them are empty.
当我检查声纳时,我在空样式文件中有代码气味:
When I check sonar I have Code smells in empty style files:
- 删除此空样式表.
- 在此文件末尾添加一个空的新行.
我应该删除声纳规则还是必须删除项目中的所有空样式文件,并在需要它们进行组件样式设计时在下一版本的项目中重新创建它们?什么是最佳做法?
Should I remove sonar rules or I must delete all empty style files in project and recreating them in next versions of project when I need them for component styling? What are best practices?
推荐答案
对我来说,您可以将CSS/SCSS文件留空. 正因为在构建之后,围绕样式的所有内容都会被最小化并包含"styles.js"文件. 因此,即使在开发人员模式下查看所有这些空文件都有些丑陋,编译器也会自行解决您的问题
For me, you can let the CSS / SCSS files empty. Just because after the build everything around styling will be minified and contained the "styles.js" file. So, even if it's a bit ugly to see all these empty files in dev mode, the compiler will solve your probelm by itself
这是构建后项目的屏幕:
this is a screen of your project after build :
这篇关于空样式(.css/.scss)文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!