Gulp 入门指南你可以下载所有示例代码或在线查看代码 建议:你可以只阅读下面的代码与注释或同时阅读代码解释 gulp 的所有配置代码都写在 gulpfile.js 文件。 ### 一、 新建一个 gulpfile.js 文件 chapter2 gulpfile.js ### 二、 在 gulpfile.js 中编写代码 // 获取 gulp var gulp = require('gulp') require() pipe 理解为将操作加入执行队列 参考:gulp API文档 ### 五、 跳转至 gulpfile.js 所在目录 打开命令行使用 cd 命令跳转至 gulpfile.js 文件所在目录。 例如我的 gulpfile.js 文件保存在 C:\gulp-book\demo\chapter2\gulpfile.js。 那么就需要在命令行输入 cd C:\gulp-book\demo\chapter2 文件夹,这里面存放着 npm 安装的模块。 目录结构: gulpfile.js node_modules gulp-uglify 接着输入 gulp script 执行任务 gulp script [13:34:57] Using gulpfile ~/Documents/code/gulp-book/demo/chapter2/gulpfile.js [13:34:57] Starting 'script'0 码力 | 36 页 | 275.87 KB | 2 年前3
Learning Gulpproject directory: ..... 3 4. Install gulp in your project devDependencies: ..... 3 5. Create a gulpfile.js at the root of your project: ..... 3 6. Run gulp: ..... 3 Task dependency ..... 3 Concat 4. Install gulp in your project devDependencies: $ npm install --save-dev gulp 5. Create a gulpfile.js at the root of your project: var gulp = require('gulp'); gulp.task('default', Browser Sync. bash $ npm install browser-sync --save-dev With that premise, let us open our gulpfile.js and add the watch functionality. Let us require browser sync and define some variables to use its0 码力 | 45 页 | 977.19 KB | 2 年前3
BabelJS Tutorial"vinyl-source-stream": "^2.0.0" } } } Let us now create the gulpfile.js, which will help run the task to bundle the modules together. We will use the same files used above "font-size:30px;color:green); The gulpfile.js is created here. A user will browserfiy and use transform to babelify. babel-preset-env is used to transpile the code to es5. ### Gulpfile.js const gulp = require('gulp'); follows:  ### gulpfile.js var gulp = require('gulp'); var babel = require('gulp-babel'); var connect =0 码力 | 173 页 | 2.70 MB | 2 年前3
TypeScript Handbook(中文版)
src WebApplication10 Properties ▶ ▶-▶ References ▶ ☐ wwwroot ▶ ▶ ▶ Dependencies scripts gulpfile.js package.json ▶ project.json Project_Readme.html $ ^{c} $ Startup.cs TypeScript Virtual Studio将开始安装gulp和del。若没有自动开始,请右击package.json文件选择Restore Packages。 ## 设置 gulp 最后,添加一个新JavaScript文件 gulpfile.js 。键入以下内容: TypeScript Handbook(中文版) ////* This file n'任务。 現在,右击 gulpfile.js 并选择Task Runner Explorer。若'default'和'clean'任务沒有顯示輸出內容的話,請刷新explorer: Task Runner Explorer WebApplication11▼Qjusdings default × Gulpfile.js Task default clean 0 码力 | 557 页 | 7.48 MB | 2 年前3
Laravel 5.3 中文文档Laravel Elixir 6.0 和 Laravel 5.3 一起发布,新版本将捆绑支持 Webpack 和 Rollup JavaScript 模块。 默认情况下,Laravel 5.3 的 gulpfile.js 文件现在已经使用 Webpack 来编译 JavaScript: elixir(mix => { mix.sass('app.scss') .webpack('app install 安装好前端依赖之后,可以使用 Gulp 编译 SASS 文件为原生的 CSS,gulp 命令 会处理 gulpfile.js 文件中的声明。通常,编译好的 CSS 文件会被放置到 public/css 目录下: gulp Laravel 自带的默认 gulpfile.js 文件会编译 SASS 文件 resources/assets/sass/app.scss,这个 app.scss 扩展包安装好之后,可以使用 gulp 命令来编译前端资源,Gulp 是一个 JavaScript 命令行构建工具,当你执行 gulp 命令的时候,Gulp 将会执行 gulpfile.js 中的声明: 默认情况下,Laravel 自带的 gulpfile.js 将会编译 SASS 和 resources/assets/js/app.js 文件,在 app.js 文件中你可以注册 Vue 组件,或者你倾向于其它0 码力 | 691 页 | 9.37 MB | 2 年前3
TypeScript 4.0 使用手册
Studio将开始安装gulp和del。若没有自动开始,请右击package.json文件选择Restore Packages。 ## 设置 gulp 最后,添加一个新JavaScript文件 gulpfile.js 。 键入以下内容: 1. //2. /* This file is the main entry Studio构建完成后,立即运行'default'任务。当你应答 Visual Studio 清除构建内容后,它也将运行'clean'任务。 现在,右击 gulpfile.js 并选择Task Runner Explorer。若'default'和'clean'任务没有显示输出内容的话,请刷新explorer: ## 编写HTML页 的一部分复制进来。我们需要添加: 1. 库文件目录。 2. 添加一个 lib 任务来输送文件到 wwwroot。 3. 在 default 任务上添加 lib 任务依赖。 更新后的 gulpfile.js 像如下所示: 1. // 2. /* This file is the main0 码力 | 683 页 | 6.27 MB | 2 年前3
Egg & Node.js 从⼩⼯坊⾛向企业级开发aead80a87a1c1e4cb414bf7cdfffc/p42_2.jpg) ## 作为团队的技术负责人 ## 你的团队是否遇到过: 维护很多个项目,每个项目都需要复制拷贝诸如 gulpfile.js /webpack.config.js 之类的文件。 每个项目都需要使用一些相同的类库,相同的配置。 在新项目中对做了一个优化后,如何同步到其他项目? 紧急修复后如何快速升级所有项目?0 码力 | 70 页 | 7.57 MB | 2 年前3
Laravel 5.1 中文文档很不方便,可以使用 gulpwatch 命令。该命令将会一直在终端运行并监控前端文件的改动。当改变发生时,新文件将会自动被编译: gulp watch ## 4、 处理 CSS 项目根目录下的 gulpfile.js 文件包含了所有的 Elixir 任务。Elixir 任务可以使用方法链的方式链接起来用于定义前端资源如何被编译。 ### 4.1 Less 要将 Less 编译成 CSS,可以使用 less Gulpfile 顶端,或者将其解析到自定义的任务文件。例如,如果你将扩展放在 elixir-extensions.js,可以在主 Gulpfile 中像这样引入该文件: // File: Gulpfile.js var elixir = require('laravel-elixir'); require('./elixir-extensions'); elixir(function(mix)0 码力 | 307 页 | 3.46 MB | 2 年前3
Laravel 5.2 中文文档很不方便,可以使用 gulp watch 命令。该命令将会一直在终端运行并监控前端文件的改动。当改变发生时,新文件将会自动被编译: gulp watch ## 4、 处理 CSS 项目根目录下的 gulpfile.js 文件包含了所有的 Elixir 任务。Elixir 任务可以使用方法链的方式链接起来用于定义前端资源如何被编译。 ### 4.1 Less 要将 Less 编译成 CSS,可以使用 less Gulpfile 顶端,或者将其解析到自定义的任务文件。例如,如果你将扩展放在 elixir-extensions.js,可以在主 Gulpfile 中像这样引入该文件: // File: Gulpfile.js var elixir = require('laravel-elixir'); require('./elixir-extensions'); elixir(function(mix)0 码力 | 377 页 | 4.56 MB | 2 年前3
共 9 条
- 1













