简体   繁体   English

将整个SCSS文件夹编译为单个CSS文件

[英]Compile entire SCSS folder into single css file

My goal is to have webpack compile all of my scss files in my styles folder into a single bundle.css file. 我的目标是让webpack将样式文件夹中的所有scss文件编译为一个bundle.css文件。

All of the tutorials that I've seen so far require that I either import all of the files into a single scss file and then compile that, or use require("filename.scss") in the javascript file. 到目前为止,我所见过的所有教程都要求我要么将所有文件导入单个scss文件,然后进行编译,要么在javascript文件中使用require("filename.scss")

Is is possible to automatically traverse all of the subfolders in the styles directory and produce a single output file without declaring or importing each file? 是否可以自动遍历styles目录中的所有子文件夹并生成一个输出文件,而无需声明或导入每个文件?

There's a reason most tutorials rely on @import rules. 大多数教程都依赖@import规则是有原因的。 Creating the base SCSS file that imports your others is an important step - that's where you determine the order that your styles are incorporated into the compiled CSS. 创建导入其他文件的基本SCSS文件是重要的一步-在这里,您可以确定将样式合并到已编译CSS中的顺序。

If you were to let a folder of .scss files be automatically combined into one .css, you could have many issues down the line if you wanted to import normalize.css , a reset file or vendor/plugin styles - those could unknowingly be altering or replacing styles you'd written. 如果要让一个.scss文件文件夹自动合并为一个.css,则如果想导入normalize.css重置文件或供应商/插件样式,可能会遇到很多问题-这些可能会在不知不觉中发生变化或替换您编写的样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM