Skip to content

Commit 3600524

Browse files
committed
Add integration documentation, use local gulp instead of globally installed gulp
1 parent 81db4a9 commit 3600524

File tree

3 files changed

+71
-33
lines changed

3 files changed

+71
-33
lines changed

README.md

Lines changed: 65 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,94 @@
11
# Magento 2 Gulp Integration
22

3-
<p>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. </p>
3+
As a Magento 2 frontend developer you might have noticed that less to css compilation process is slow with grunt and it
4+
takes more time to rebuild everything making you an inefficient developer.
45

5-
<p>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. </p>
6+
However, you could solve this problem with Gulp. Gulp is a task / build runner which uses Node.js for web development.
7+
The main difference between Gulp and Grunt lies in how they deal with their automation tasks inside.
68

7-
<p>Gulp uses Node Stream while Grunt uses temp files. Therefore, Gulp compilation is faster compared to Grunt. </p>
9+
Gulp uses Node Stream while Grunt uses temp files. Therefore, Gulp compilation is faster compared to Grunt.
810

11+
## Comparing with Grunt
912

10-
<h2>Comparing with Grunt</h2>
1113
<table>
1214
<tr><th></th><th>Gulp</th><th>Grunt</th></tr>
1315
<tr><td>Compilation of all themes (10 files):</td><td>16sec</td><td>33sec</td></tr>
1416
<tr><td>Custom theme compilation (2 files)</td><td>4.5s</td><td>11.2s</td></tr>
1517
</table>
1618

17-
<h2>Installation</h2>
19+
## Installation
1820

19-
1. Download as a zip file or clone this in to ur pc.
21+
### Method 1: Install using composer (only for Magento >= 2.2.2)
2022

21-
2. Copy "gulpfile.js" and "package.json" in to the root directory (code pool)
23+
1. Ensure Node is used in Version 11: `nvm install v11`
2224

23-
2.2. If you are using Magento 2.2.1 or lower comment line number 47 - 48
25+
2. Add the composer repository `composer config repositories.gulp vcs https://github.com/subodha/magento-2-gulp.git`
26+
27+
3. Install the module `composer require subodha/magento-2-gulp:"1.*"`
28+
29+
4. Add these scripts to your composer.json:
30+
31+
```json
32+
{
33+
"scripts": {
34+
"post-update-cmd": [
35+
"cd vendor/subodha/magento-2-gulp && npm install"
36+
],
37+
"post-install-cmd": [
38+
"cd vendor/subodha/magento-2-gulp && npm install"
39+
]
40+
}
41+
}
42+
```
43+
44+
5. Run `composer install`
45+
46+
6. Define your theme configuration in `dev/tools/grunt/configs/themes.js`
47+
48+
7. You can now run `vendor/bin/gulpm2 build --your_theme` to compile your styles
49+
50+
### Method 2: Copying to your Magento installation (old method for Magento <= 2.2.1)
51+
52+
1. Download as a zip file or clone this repository.
53+
54+
2. Copy "gulpfile.js" and "package.json" in to the root directory (code pool).
55+
56+
If you are using Magento 2.2.1 or lower comment line number 47 - 48.
2457

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

27-
4. Install gulp globally using <code>npm install -g gulp-cli</code>
60+
4. Install gulp globally using `npm install -g gulp-cli`
2861

2962
5. Install modules: run a command in a root directory of your project "npm install".
30-
<br>(If you already installed Grunt please remove node_module directory)
3163

32-
<h2>How to run</h2>
64+
(If you already installed Grunt please remove node_module directory)
3365

34-
1. Run <code>gulp exec --theme</code> ex: gulp exec --luma
35-
<br>Or: <code>php bin/magento dev:source-theme:deploy --locale="en_AU" --area="frontend" <br>--theme="
36-
VendorName/themeName"</code>
66+
## How to run
3767

38-
2. Run : <code>gulp deploy --theme</code> ex: gulp deploy --luma
39-
<br>Or: <code>php bin/magento setup:static-content:deploy en_AU</code>
68+
1. Run `gulp exec --theme` ex: `gulp exec --luma`
69+
<br>Or: `php bin/magento dev:source-theme:deploy --locale="en_AU" --area="frontend" <br>--theme="
70+
VendorName/themeName"`
71+
72+
2. Run : `gulp deploy --theme` ex: `gulp deploy --luma`
73+
<br>Or: `php bin/magento setup:static-content:deploy en_AU`
4074

4175
3. Run gulp command in the root directory with arguments or without. Examples:<br>
42-
3.a. Compilation of all themes: <code>gulp</code><br>
43-
3.b. Compilation of certain theme: <code>gulp less --luma</code><br>
44-
3.c. Watcher of certain theme: <code>gulp watch --luma</code><br>
45-
3.d. Compilation of certain theme with minification (+~2.5s): <code>gulp less --luma --min</code><br>
46-
3.e. Compilation of certain theme with sourcemap(+~1.5s), can't be used with minification: <code>gulp less --luma
47-
--map</code><br>
48-
3.f. Compilation with live reload: <code>gulp less --luma --live</code><br>
49-
3.g. Watcher with liveReload: <code>gulp watch --luma --live</code><br>
50-
3.h. For clear the magento cache: <code>gulp cache-flush</code><br>
76+
3.a. Compilation of all themes: `gulp`<br>
77+
3.b. Compilation of certain theme: `gulp less --luma`<br>
78+
3.c. Watcher of certain theme: `gulp watch --luma`<br>
79+
3.d. Compilation of certain theme with minification (+~2.5s): `gulp less --luma --min`<br>
80+
3.e. Compilation of certain theme with sourcemap(+~1.5s), can't be used with
81+
minification: `gulp less --luma --map`<br>
82+
3.f. Compilation with live reload: `gulp less --luma --live`<br>
83+
3.g. Watcher with liveReload: `gulp watch --luma --live`<br>
84+
3.h. For clear the magento cache: `gulp cache-flush`<br>
5185

5286
4. For using liveReload install extension for your browser: https://livereload.com/
5387
<br>4.a. Turn on the extension on the page of project.
5488

55-
5. For clear the magento cache: gulp cache-flush
56-
6. For clear the magento static files cache: gulp clean --luma
89+
5. For clear the magento cache: `gulp cache-flush`
90+
6. For clear the magento static files cache: `gulp clean --luma`
91+
92+
### How to run (with composer integration)
93+
94+
See above, but replace `gulp` with `vendor/bin/gulpm2`.

bin/gulpm2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ fi
1313
PACKAGE_DIR=$(dirname $SCRIPT_PATH)/../
1414

1515
# execute gulp with given parameters
16-
gulp -f=$PACKAGE_DIR/gulpfile.js --cwd=$PWD "$@"
16+
$PACKAGE_DIR/node_modules/gulp/bin/gulp.js -f=$PACKAGE_DIR/gulpfile.js --cwd=$PWD "$@"

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "magento-2-gulp",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "Generating stylesheets for Magento 2 with gulp",
55
"homepage": "https://github.com/subodha/magento-2-gulp#readme",
66
"license": "GPL-3.0",
@@ -22,14 +22,14 @@
2222
},
2323
"main": "gulpfile.js",
2424
"devDependencies": {
25-
"colors": "^1.3.0",
25+
"colors": "^1.4.0",
2626
"gulp": "^4.0.2",
2727
"gulp-cssmin": "^0.2.0",
28-
"gulp-if": "^2.0.2",
28+
"gulp-if": "^3.0.0",
2929
"gulp-less": "^4.0.1",
30-
"gulp-livereload": "^3.8.1",
30+
"gulp-livereload": "^4.0.2",
3131
"gulp-sourcemaps": "^1.12.1",
3232
"gulp-svg-sprites": "^4.1.2",
33-
"underscore": "^1.9.1"
33+
"underscore": "^1.13.1"
3434
}
3535
}

0 commit comments

Comments
 (0)