• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

subodha/magento-2-gulp: Gulp for Magento 2

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

subodha/magento-2-gulp

开源软件地址(OpenSource Url):

https://github.com/subodha/magento-2-gulp

开源编程语言(OpenSource Language):

JavaScript 94.0%

开源软件介绍(OpenSource Introduction):

Magento 2 Gulp Integration

As a Magento 2 frontend developer you might have noticed that less to css compilation process is slow with grunt and it takes more time to rebuild everything making you an inefficient developer.

However, you could solve this problem with Gulp. Gulp is a task / build runner which uses Node.js for web development. The main difference between Gulp and Grunt lies in how they deal with their automation tasks inside.

Gulp uses Node Stream while Grunt uses temp files. Therefore, Gulp compilation is faster compared to Grunt.

Comparing with Grunt

GulpGrunt
Compilation of all themes (10 files):16sec33sec
Custom theme compilation (2 files)4.5s11.2s

Installation

Method 1: Install using composer (only for Magento >= 2.2.2)

  1. Ensure Node is used in Version 11: nvm install v11

  2. Add the composer repository composer config repositories.gulp vcs https://github.com/subodha/magento-2-gulp.git

  3. Install the module composer require subodha/magento-2-gulp:"1.*"

  4. Add these scripts to your composer.json:

{
    "scripts": {
        "post-update-cmd": [
            "cd vendor/subodha/magento-2-gulp && npm install"
        ],
        "post-install-cmd": [
            "cd vendor/subodha/magento-2-gulp && npm install"
        ]
    }
}
  1. Run composer install

  2. Define your theme configuration in dev/tools/grunt/configs/themes.js

  3. You can now run vendor/bin/gulpm2 build --your_theme to compile your styles

Method 2: Copying to your Magento installation (old method for Magento <= 2.2.1)

  1. Download as a zip file or clone this repository.

  2. Copy "gulpfile.js" and "package.json" in to the root directory (code pool).

    If you are using Magento 2.2.1 or lower comment line number 47 - 48.

  3. Install node.js for your OS: https://nodejs.org/en/

  4. Install gulp globally using npm install -g gulp-cli

  5. Install modules: run a command in a root directory of your project "npm install".

    (If you already installed Grunt please remove node_module directory)

How to run

  1. Run gulp exec --theme ex: gulp exec --luma
    Or: php bin/magento dev:source-theme:deploy --locale="en_AU" --area="frontend" <br>--theme=" VendorName/themeName"

  2. Run : gulp deploy --theme ex: gulp deploy --luma
    Or: php bin/magento setup:static-content:deploy en_AU

  3. Run gulp command in the root directory with arguments or without. Examples:
    3.a. Compilation of all themes: gulp
    3.b. Compilation of certain theme: gulp less --luma
    3.c. Watcher of certain theme: gulp watch --luma
    3.d. Compilation of certain theme with minification (+~2.5s): gulp less --luma --min
    3.e. Compilation of certain theme with sourcemap(+~1.5s), can't be used with minification: gulp less --luma --map
    3.f. Compilation with live reload: gulp less --luma --live
    3.g. Watcher with liveReload: gulp watch --luma --live
    3.h. For clear the magento cache: gulp cache-flush

  4. For using liveReload install extension for your browser: https://livereload.com/
    4.a. Turn on the extension on the page of project.

  5. For clear the magento cache: gulp cache-flush

  6. For clear the magento static files cache: gulp clean --luma

How to run (with composer integration)

See above, but replace gulp with vendor/bin/gulpm2.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap