gulp-sass_如果您是初学者,如何使用命令行设置Gulp-sass
gulp-sass
by Simeon Bello
通过Simeon Bello
I intern at a tech firm presently, and few days ago I got a challenge from my boss about writing an article. So I decided to write something on Gulp-sass. Setting it up can be frustrating sometimes, especially when you are new to it. I use Windows, and searching for an article that would solve my problem was like getting Jack in Black-ish to spell “decrease”.
我目前在一家科技公司实习,几天前,我的老板在撰写文章方面遇到了挑战。 所以我决定在Gulp-sass上写点东西。 设置它有时可能会令人沮丧,尤其是当您不熟悉它时。 我使用Windows,并且寻找可以解决我问题的文章,就像让Jack用黑话拼写“减少”一样。
Ok I think I got a little bit carried away there…enough about me, let’s get started!
好吧,我想我在那里有点儿迷路了……对我来说足够了,让我们开始吧!
P.S. this is my first published article and I hope you love it. :)
附言:这是我的第一篇文章,希望您喜欢。 :)
安装节点 (Installing node)
First, open the command line and install node.js on your computer. It comes with a Node Package Manager(npm) which you can use to install Gulp. After installing, you can install Gulp by running npm install gulp -g
. The -g
instructs npm to install Gulp globally on your computer (this means that you can use gulp commands anywhere on your computer.)
首先,打开命令行并在计算机上安装node.js。 它带有一个Node Package Manager(npm),可用于安装Gulp。 安装后,您可以通过运行npm install gulp -g
来安装Gulp。 -g
指示npm在您的计算机上全局安装Gulp(这意味着您可以在计算机上的任何位置使用gulp命令。)
Before I continue, I am assuming you are familiar with the command line!
在继续之前,我假设您熟悉命令行!
Navigate to your project directory and run npm init
. This will create a package.json file, press enter and it will add what you need intothe package.json file.
导航到您的项目目录,然后运行npm init
。 这将创建一个package.json文件,按Enter键,它将需要的内容添加到package.json文件中。
Yeah, you may be wondering what a package.json file is right?A package.json file holds various metadata relevant to your project. This file gives information to npm and allows it to identify the project as well as handle the project’s dependencies. It also makes it easier to install all the tasks that are used in a Gulp project.
是的,您可能想知道一个package.json文件是正确的吗? package.json文件包含与您的项目相关的各种元数据。 该文件将信息提供给 npm 并允许它标识项目并处理项目的依赖项。 它还使安装Gulp项目中使用的所有任务更加容易。
If you still don’t get it, you probably need Diane to explain it better — what is my problem/obsession with Black-ish??
如果您仍然不了解它,您可能需要戴安娜(Diane)更好地解释它-我对黑眼鲨的问题/痴迷是什么?
After running npm-init
, type npm install gulp --save-dev
, this instructs npm to install Gulp into your project. By using --save-dev
we store Gulp as a dev dependency in the package.json.
运行npm-init
,键入npm install gulp --save-dev
,这指示npm将Gulp安装到您的项目中。 通过使用 --save-dev
我们将Gulp作为dev依赖项存储在package.json中。
创建一个Gulpfile (Creating a Gulpfile)
Now that you’ve installed Gulp, you’re ready to install the first task. You have to require
Gulp. Create a new file called gulpfile.js in your project directory — You can do this by using any text editor. Start by adding the code below to your gulpfile.
既然您已经安装了Gulp,就可以开始安装第一个任务了。 您必须require
Gulp。 在项目目录中创建一个名为gulpfile.js的新文件-您可以使用任何文本编辑器来完成此操作。 首先将以下代码添加到您的gulpfile中。
‘use strict’;
var gulp = require(‘gulp’);
设置任务 (Setting up a task)
Now you can install a gulp task — in this case we would install Gulp-sass. This task makes it possible to convert Sass to CSS. Still using the command line, you can install Gulp-sass by running npm install gulp-sass --save-dev
. After that, require Gulp-sass in your gulpfile.js.
现在,您可以安装gulp任务-在这种情况下,我们将安装Gulp-sass。 通过此任务,可以将Sass转换为CSS 。 仍然使用命令行,您可以通过运行npm install gulp-sass --save-dev
来安装Gulp-sass。 之后,在您的gulpfile.js中要求Gulp-sass。
Put var sass = require(‘gulp-sass’);
under the line you required gulp.
把var sass = require('gulp-sass');
在您需要的行下面。
构建项目 (Structuring your project)
Before you use the lines below, I am also assuming you know how to structure a web app. Here I am going to use the structure of common web apps.
在使用下面的代码行之前,我还假设您知道如何构建Web应用程序。 在这里,我将使用常见Web应用程序的结构。
编译sass / scss (Compiling sass/scss)
The last thing then is to instruct gulp what files it needs to convert and where the destination should be — where the output file will be stored.
然后,最后一件事是指示gulp需要转换哪些文件以及目标应该在哪里-输出文件将存储在哪里。
Use the following;
使用以下内容;
//compile gulp.task(‘sass’, function () { gulp.src(‘app/scss/app.scss’) .pipe(sass().on(‘error’, sass.logError)) .pipe(gulp.dest(‘app/css’)); });
The file in gulp.src will be converted, you can also select all .scss files in a directory by using “app/scss/*.scss”
. This will select all your .scss files in the folder scss.
gulp.src中的文件将被转换,您也可以使用“app/scss/*.scss”
选择目录中的所有.scss文件。 这将选择文件夹scss中的所有.scss文件。
The gulp.dest is the output. The output will be stored in the CSS folder inside the app folder.
gulp.dest是输出。 输出将存储在app文件夹内CSS文件夹中。
喝水 (Gulp-watch-sass)
Gulp has a watch syntax which allows it to monitor source files and then “watch” for changes made to your code. Just add the syntax to your gulpfile.js by typing:
Gulp具有监视语法,可以监视源文件,然后“监视”对代码所做的更改。 只需通过输入以下命令将语法添加到您的gulpfile.js中:
//compile and watch gulp.task(‘sass:watch’, function() { gulp.watch(‘app/scss/app.scss’, [‘sass’]);});
That’s pretty much everything you have to do! It wasn’t that stressful, or was it?
这几乎就是您要做的一切! 压力不是那么大吗?
Thanks for reading!
谢谢阅读!
翻译自: https://www.freecodecamp.org/news/how-to-set-up-gulp-sass-using-the-command-line-if-youre-a-beginner-17729f53249/
gulp-sass
相关文章:

MyEclipse快捷键
MyEclipse快捷键 Ctrl1 快速修复CtrlD: 删除当前行 CtrlQ 定位到最后编辑的地方 CtrlL 定位在某行 CtrlO 快速显示 OutLine CtrlT 快速显示当前类的继承结构 CtrlW 关闭当前Editer CtrlK 快速定位到下一个 CtrlE 快速显示当前Editer的下拉列表CtrlJ 正向增量查找(按下C…

关于UNION和UNION ALL的区别
今天在运行程序的时候发现个问题,就是计算和的时候两条数据一样的话自动去除重复的,可是我这个程序需要重复的数据也算进来呀,然后就找原因,最后在sql语句中找到了是union和union all的问题,简单总结一下下。 当使用到…

html 写一个日志控件 查看log
QQ技术交流群 173683866 526474645 欢迎加入交流讨论,打广告的一律飞机票 使用场景, 示例访问:https://weixin.njkeren.cn/test1.html?user12 得到的效果图 实现代码 <!DOCTYPE html> <html><head><meta charset&q…

python开源项目贡献_通过为开源项目做贡献,我如何找到理想的工作
python开源项目贡献by Utsab Saha由Utsab Saha 通过为开源项目做贡献,我如何找到理想的工作 (How I found my dream job by contributing to open source projects) One of the concerns I often hear about from my coding students is, “How am I going to land…

JSON解析与XML解析的区别
JSON与XML的区别比较 1.定义介绍 (1).XML定义扩展标记语言 (Extensible Markup Language, XML) ,用于标记电子文件使其具有结构性的标记语言,可以用来标记数据、定义数据类型,是一种允许用户对自己的标记语言进行定义的源语言。 XML使用DTD(d…

[matlab]Monte Carlo模拟学习笔记
理论基础:大数定理,当频数足够多时,频率可以逼近概率,从而依靠概率与$\pi$的关系,求出$\pi$ 所以,rand在Monte Carlo中是必不可少的,必须保证测试数据的随机性。 用蒙特卡洛方法进行计算机模拟的…

vue 网络请求 axios vue POST请求 vue GET请求 代码示例
QQ技术交流群 173683866 526474645 欢迎加入交流讨论,打广告的一律飞机票 1.安装 axios 和 vue-axios 和 qs (qs是为了解决post默认使用的是x-www-from-urlencoded 请求,导致请求参数无法传递到后台) $ npm install --save axio…

bff v2ex_语音备忘录的BFF-如何通过Machine Learning简化Speech2Text
bff v2exby Rafael Belchior通过拉斐尔贝尔基奥尔(Rafael Belchior) 语音备忘录的BFF-如何通过Machine Learning简化Speech2Text (The voice memo’s BFF — how to make Speech2Text easy with Machine Learning) Do you think recording voice memos is inconvenient becaus…

pat1094. The Largest Generation (25)
1094. The Largest Generation (25) 时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to …

web-view里面的网页能请求未配置的request域名吗
QQ技术交流群 173683866 526474645 欢迎加入交流讨论,打广告的一律飞机票 可以

.NET调用JAVA的WebService方法
调用WebService,最简单的办法当然是直接添加WEB引用,然后自动产生代理类,但是在调用JAVA的WebService时并没有这么简单,特别是对于SoapHeader的处理,在网上也有相关资料,但是都整理的不够清晰明了。根据网上…

适合初学者的数据结构_数据结构101:图-初学者的直观介绍
适合初学者的数据结构了解您每天使用的数据结构 (Get to know the data structures that you use every day) Welcome! Let’s Start with Some Vital Context. Let me ask you something:✅ Do you use Google Search? ✅ Do you use Google Maps? ✅ Do you use social med…

深入解析CSS样式层叠权重值
本文为转载内容,源地址:http://www.ofcss.com/2011/05/26/css-cascade-specificity.html 读到《重新认识CSS的权重》这篇,在文章最后给出了便于记忆的顺序: “important > 内联 > ID > 类 > 标签 | 伪类 | 属性选择 &…

VUE做一个公共的提示组件,显示两秒自动隐藏,显示的值父组件传递给子组件
需求:VUE做一个公共的提示组件,显示两秒自动隐藏,显示的值由父组件动态传给子组件。 效果图: 实现步骤: 1.创建一个子组件 Toptips.vue (它就是公共提示组件), optips.vue代码如下: <temp…

Linux课堂随笔---第四天
用户账户简介 在Linux系统中有三大类用户,分别是root用户,系统用户和普通用户。 在Linux系统中,root用户UID为0,root用户的权限是最高的,普通用户无法执行的操作,root用户都能完成。所以也被称为超级用户。…

初级开发人员的缺点_作为一名初级开发人员,我如何努力克服自己的挣扎
初级开发人员的缺点by Syeda Aimen Batool通过Syeda Aimen Batool 作为一名初级开发人员,我如何努力克服自己的挣扎 (How I’m working to overcome my struggles as a junior developer) I believe the other name for coding is the “struggle”. And if you ar…

lintcode-136-分割回文串
136-分割回文串 给定一个字符串s,将s分割成一些子串,使每个子串都是回文串。 返回s所有可能的回文串分割方案。 样例 给出 s "aab",返回 [ ["aa", "b"], ["a", "a", "b"] ] 标…

微信小程序把繁琐的判断用Js简单的解决
场景: 订单列表,有很多种订单状态,根据不同的订单状态要显示不同的css。 适用场景:需要根据数组下标判断不同的显示。 示例代码: this.data.order [{"_type":"1","custName":"…

数论(Lucas定理) HDOJ 4349 Xiao Ming's Hope
题目传送门 题意:求C (n,0),C (n,1),C (n,2)...C (n,n)中奇数的个数 分析:Lucas 定理:A、B是非负整数,p是质数。AB写成p进制:Aa[n]a[n-1]...a[0],Bb[n]b[n-1]...b[0]。则组合数C(A,B)与C(a[n],b[n])*C(a[n-…

docker容器虚拟化技术_Docker,虚拟机和容器的全面介绍
docker容器虚拟化技术by shota jolbordi通过Shota Jolbordi Docker has been a buzzword for tech people for the last several years, and the more times goes by, the more often you hear about it. We’re seeing it more in job requirements, and more companies are …

IOS中的响应者链
响应者链就是当子视图不响应,父视图有响应事件,父视图响应 #import "RootViewController.h" #import "ResponderView.h" interface RootViewController ()endimplementation RootViewController- (void)viewDidLoad {[super viewDidLoad];// Do any additi…

MySQL闪退问题的解决
刚刚学习了数据库,并且安装了MySQL,正当高兴之余,发现我的MySQL出现了闪退的显现。上网搜了好久的解决方案。最后解决了这个问题,也舒心了。 问题从这里开始: 接着我打开MySQL,寻思能不能用,结果…

HTML封装AJAX请求,在请求里面写登录的逻辑 ajax 网络请求 post
调用方法: 先引用config.js,然后调用封装网络请求。 里面三个参数 1.url, 2.请求需要提交的数据, 3.请求类型 // 获取二维码、背景图片接口 getScheduleInfo() {var url /v1/basketball/getQRCode.do;var params {phone: 13977284414}co…

oye pandora_我尝试了Pandora出色的功能优先级排序方法。 这是我学到的。
oye pandoraby Josh Temple通过乔什坦普尔 我尝试了Pandora出色的功能优先级排序方法。 这是我学到的。 (I tried Pandora’s brilliant method for feature prioritization. Here’s what I learned.) 潘多拉(Pandora)的方法和3美元的便签纸如何使利益相关者的管理变得轻而易…

2016-2017-2软件工程课程总结
2016-2017-2软件工程课程总结 本学期的软件工程课程终于在大家的共同努力下圆满落幕了,我们的暑假也正式开启,终于有时间写写这门课的总结了。 在2016年下半学期末的时候课程组就决定使用邹欣老师的书《构建之法》,由课程组长王瑞老师带领入构…

asp.net mvc jqgrid 同一个页面查询不同的表,jqgrid显示不同表的表头和数据并且分页...
基于我上一篇文章<a href"http://www.cnblogs.com/alasai/p/4765756.html">asp.net mvc excel导入</a>中不同的部门上传不同的excel文件类型,当在同一个页面查询时怎么办呢。 解决方案:根据传过来的表名和时间参数一次性把数据全部…

降维后的高维特征的参数_高维超参数调整简介
降维后的高维特征的参数by Thalles Silva由Thalles Silva 高维超参数调整简介 (An introduction to high-dimensional hyper-parameter tuning) 优化ML模型的最佳做法 (Best practices for optimizing ML models) If you ever struggled with tuning Machine Learning (ML) mo…

细细品味大数据--初识hadoop
初识hadoop 前言 之前在学校的时候一直就想学习大数据方面的技术,包括hadoop和机器学习啊什么的,但是归根结底就是因为自己太懒了,导致没有坚持多长时间,加上一直为offer做准备,所以当时重心放在C上面了(虽…

js中Array数组中的常用方法汇总
Array的push与unshift方法性能比较分析从原理就可以知道,unshift的效率是较低的。原因是,它每添加一个元素,都要把现有元素往下移一个位置。unshift比push要慢差不多100倍!Array有一个叫做reverse的方法,能够把一个数组…

vue写一个通用的toast弹窗 toast 弹窗 提示
效果图 代码 <!DOCTYPE html> <html lang"en"><head><title>弹窗</title><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0, user-scalableno, minimum-s…