在前端开发中,Gulp 是角色分明的构建工具,用来自动化地完成任务,如编译 sass、压缩 JS、复制文件等等。而 th-gulphelpers 则为 Gulp 开发者提供了很多辅助函数,提高了 Gulp 的使用体验和效率。本文将为大家介绍 th-gulphelpers 的使用方法。
安装
使用 npm 安装 th-gulphelpers:
--- ------- -------------- ----------
使用
在 Gulpfile 中引入 th-gulphelpers:
----- ---- - ---------------- ----- ------- - --------------------------
1. 使用的工作目录
helpers.WorkingDirectory
可以用于获取当前的工作目录。
示例代码:
----- ---------- - ------------------------------- ------------------------ -- -------------------------
2. 编译 Sass
helpers.Sass.compile()
可以用于编译 Sass。
示例代码:
----- ---- - --------------------- ----------------- ---------- - ------ -------------------------------- ------------------------ --------------- ------------------------------- ---
3. 压缩 JavaScript
helpers.JS.uglify()
可以用于压缩 JavaScript。
示例代码:
----- ------ - ----------------------- --------------- ---------- - ------ ---------------------------- -------------------------- ------------------------------ ---
4. 复制文件
helpers.Files.copy()
可以用于复制文件。
示例代码:
----------------- ---------- - ------ ----------------------------- ------------------------------------------- ---
总结
以上就是 th-gulphelpers 的使用教程。通过使用 th-gulphelpers,我们可以更加便捷地使用 Gulp 完成各种任务,提高代码的开发效率。
来源:JavaScript中文网 ,转载请联系管理员! 本文地址:https://www.javascriptcn.com/post/5eedc056b5cbfe1ea0611c87