马文的地下室

学习笔记《gulp》

2016-09-20  本文已影响66人  马文Marvin

gulp 的作者是 Eric Schoffstall,今年应该只有22岁,The DigitalOcean Team 两年前评选的《20 Developers To Follow In 2014》中对他的介绍是:

This twenty year old star is one of our favorite rising developers. Despite his age, he's already been a featured speaker at numerous community JS events, traveling around the world when taking a break from coding. He founded Fractal in 2010, which does huge amounts of open source and consulting, and has created over 150 projects in his spare time.

gulp 是 Laravel 默认绑定的前端的前端构建工具,类似于对于 webpack 这种解析工具的工程化封装,提供了这些功能:

gulp 的安装:
npm install --global gulp-cli

然后会调用目录里面的 gulpfile.js 文件进行构建,命令是:
gulp

gulp 也支持插件的机制,目前官方有2600多个插件:
http://gulpjs.com/plugins/
github gulp首页上推荐的几个插件:

Laravel 中的使用

Laravel 在具体使用的时候,使用:

laravel-elixir
laravel-elixir-vue

两个包对 gulp 进行了封装:

Laravel Elixir provides a clean, fluent API for defining basic Gulp tasks for your Laravel application. Elixir supports common CSS and JavaScript pre-processors like Sass and Webpack. Using method chaining, Elixir allows you to fluently define your asset pipeline. For example:

elixir(function(mix) {
    mix.sass('app.scss')
       .webpack('app.js');
});

具体使用的时候可以学习这篇文章:《Run Gulp Tasks in Laravel Easily with Elixir》
还有官方文档: 《Compiling Assets (Laravel Elixir)》

上一篇 下一篇

猜你喜欢

热点阅读