简体   繁体   English

分离 SCSS 和 CSS 文件

[英]Separating SCSS and CSS files

This is my website folder structure:这是我的网站文件夹结构:

/images
/fonts
/js
/styles /    
        scss/
            |
            |– utilities/
            |   |– variables.scss  
            |
            |– base/
            |   |– reset.scss       
            |   |– typo.scss        
            |
            |– pages/
            |   |– index.scss       
            |   |– page1.scss            
            |
            – main.scss            

        css/ 
            // Save CSS Here

index.html

Description:描述:

I have a root folder, contains index.html and few folders, like fonts , js , styles ... In the styles folder, there's two folder, scss and css .我有一个root文件夹,包含index.html和几个文件夹,如fontsjsstyles ......在styles文件夹中,有两个文件夹, scsscss and in the scss folder, there's main.scss (which contains all the scss -imported-), and few folders with scss files, like: base , utilities , pages ...而在scss文件夹中,有main.scss (其中包含所有scss -imported-),并与几个文件夹scss文件,如: baseutilitiespages ...

The Problem:问题:

When I create a scss files the compiler creates the css and css.map in the same folder of the scss file that been created.当我创建一个scss文件的compiler创建csscss.map同一文件夹scss是被创建的文件。 For example, after creating variables.scss it'll look like this:例如,在创建variables.scss它看起来像这样:

|– utilities/
            |   |– variables.css   
            |   |– variables.css.map   
            |   |– variables.scss   

The Question:问题:

How can I separate the two types of files in different folders to look exactly like the example below?如何将不同文件夹中的两种类型的文件分开,使其看起来与下面的示例完全相同?

What I'm Trying To Achieve:我正在努力实现的目标:

/images
/fonts
/js
/styles /    
        scss/
            |
            |– utilities/
            |   |– variables.scss  
            |
            |– base/
            |   |– reset.scss       
            |   |– typo.scss        
            |
            |– pages/
            |   |– index.scss       
            |   |– page1.scss            
            |
            – main.scss            

        css/ 
            |
            |– utilities/
            |   |– variables.css
            |
            |– base/
            |   |– reset.css
            |   |– typo.scss
            |
            |– pages/
            |   |– index.css
            |   |– page1.css
            |
            – main.css

index.html

i suggest using live sass compiler for transpiling scss files for trying this : go to我建议使用实时 sass 编译器来转译 scss 文件以尝试此操作:转到

menu- file>preferences>settings>extension>live sass copile config>edit in settings.json菜单-文件>首选项>设置>扩展>实时sass copile配置>在settings.json中编辑

and paste this: (your save path can be customized)并粘贴:(您的保存路径可以自定义)

"liveSassCompile.settings.formats": [
{
  "format": "expanded",
  "extensionName": ".css",
  "savePath": "./css/"
}

] ]

You need to rename the files you don't want to generate a CSS to have a underscore "_" before the name.您需要将不想生成 CSS 的文件重命名为名称前带有下划线"_" And don't worry you don't need to change the name in the imports, SASS do that to you.不要担心您不需要更改导入中的名称,SASS 会为您做这些。

So your variables file would be _variables.scss所以你的变量文件将是_variables.scss

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

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