何时编译 SASS [英] when to compile SASS

查看:24
本文介绍了何时编译 SASS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Web 开发的新手.我已经阅读了有关 SCSS/SASS 的内容,我意识到它不是浏览器所寻找的,因此应该将其编译为纯 CSS.我的问题是我做对了吗:

  • 每当我对 SCSS 文件进行更改时,我都应该编译它,然后查看结果.

  • 每当我想更新我的网站时,我都应该在我的服务器端有一个特殊的脚本来将新的 SCSS 文件转换为纯 CSS,并且每次更新只会发生一次.(CSS 文件的数量很多,我希望在我的存储库中只保留 SCSS).

如果您有任何进一步的信息,我将不胜感激.

tnx 很多

解决方案

为了将 SCSS 编译为 CSS,我们使用了任务运行器,例如 Gulpstrong>、Webpack 等.我将以 Gulp 为例进行说明.

什么是 Gulp?

<块引用>

Gulp 是在前端 Web 开发过程中用作流式构建系统的任务运行器.主要用于 Web 开发中涉及的耗时和重复性任务的自动化,如缩小、连接、编译、单元测试、linting、优化等.

您可以使用 Gulp 来编译您的 SCSScode CSS 并通过 gulp,您还可以实时监视更改.

要安装 Gulp,您必须在系统中安装 Node Js.之后使用 npm i gulp-cli -g 安装 gulp.您可以在其官方网站上找到使用信息.

要将SCSS 编译设置为CSS,这是您可以找到的关于开始使用 Gulp 进行 SCSS 编译和其他任务的最佳文章.Gulp 初学者

I am new to web development. I have read about SCSS/SASS and I realized it is not what the browser looks for, so it should be compiled to pure CSS. My question is did I get it right:

  • whenever I make a change to my SCSS file, I should then compile it and then see the result.

  • whenever I want to update my website, I should have a special script on my server side to translate the new SCSS files to pure CSS and that happens only once per update. (The number of CSS files is high and I wish to keep only the SCSS on my repository).

I would be thankful If you have any further information.

tnx a lot

解决方案

For compiling the SCSS to CSS, we use task runners such as Gulp, Webpack etc. I'll explain taking Gulp is an example.

What is Gulp?

Gulp is task runner used as a streaming build system in front-end web development process. Mainly used the automation of time-consuming and repetitive tasks involved in web development like minification, concatenation, compilation, unit testing, linting, optimization, etc.

You can use Gulp for compiling your SCSScode CSS and through gulp, you can also keep watch over the changes live.

To install Gulp you must have Node Js install in your system. After that use npm i gulp-cli -g to install gulp. You can find usage information on its official website.

To setup SCSS compilation to CSS, this is the best article you can find to getting started with Gulp for SCSS compilation and other tasks. Gulp for Beginners

这篇关于何时编译 SASS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆