
Gulp works by invoking a file called gulpfile.js in your main directory, which you'll need to create and set up yourself (sorry). The limited scope of plugins entails a bit of setup in our gulpfile to chain said tasks together, but it also makes Gulp highly customizable to cater to your specific needs. Each individual plugin typically covers a simple task, such as compiling LESS or SASS files, or minifying client-side JavaScript and CSS.

Gulp doesn't do much on its own the true magic lies within its vast library of plugins.
GULP LIVERELOAD FASTER INSTALL
Next, enter your project folder and install gulp while saving it as a project dependency. An Express file structure utilizing this would look something like this: |- src/įirst install the gulp CLI: npm install -global gulp-cli That means we can keep our horrible uncompressed and uncompiled source in a folder such as /src, and output them to a directory such as /dist, which would be our public-facing output. As opposed to developing and storing files in a directory such as /public, Gulp enables us to develop in one directory, and compile to another. Let's say you're running a basic Express app. This includes minifying files to make them run faster, and to also make them unreadable to people who would otherwise make fun of your mediocre Javascript which you were forced to crank out on a short timeline.
GULP LIVERELOAD FASTER CODE
NodeJS developers use Gulp to automate necessary processes before moving their frontend code to production. Regardless, we all need our own copy+paste references from time-to-time, or even worse: when we copy/paste our gulpfile.js from project to project and forget what they actually do. You know the ones: Gulp, ExpressJS, NodeJS, or perhaps even React Vue frontend Ubuntu framework API social cloud data entrepreneur community. Haters may do as they will, but I 'll take any opportunity to jam as many SEO keywords I can get at this point. Perhaps the whole obligatory-Gulp-tutorial on thing has become a bit cliché at this point.

Gulp.watch(assetstowatch,gulp.NOTE: This tutorial was written for Gulp versions 4.0.0 Var actualwinpath = path.relative(process.cwd(),resolve(file)) Īssetstowatch.push(actualwinpath.replace(/\\/g,"/"))
GULP LIVERELOAD FASTER HOW TO
How to accomplish this task for resolving all of the symlinks to array of actual paths? So that assetstowatch is an array of all the files that needed to be watched. What I want to do is to resolve all the symlinks inside pub directory for gull watch so that when any of the file changes, I can automate the process and compile less files.īut as gulp not watches for symlinks, I decided to make it as a glob pattern and resolve these all files and tried to make array of those all resolved files so that afterwards I can simply put that array inside gulp.watch function like that.īut because pubdir variable is glob, node filesystem function realpathSync is not accepting it as an argument and throws the error about ** is not a directory. Now as per the code, I first import all the plugins and then made a custom config object for theme name and locale in Magento. Var assetstowatch = fs.realpathSync(pubdir) Var cssdir = 'pub/static/frontend/' + themeconfig.name + '/' + themeconfig.locale + '/' + 'css/' Var pubdir = 'pub/static/frontend/' + themeconfig.name + '/' + themeconfig.locale + '/**/*.less'

browserSync = require('browser-sync').create() var fs = require('fs'),Īutoprefixer = require('gulp-autoprefixer'), This is the initial code for gulpfile.js in the root of the Magento application. Gulp has many features and it is super fast then grunt.So far I have installed gulp, gulp-less and gulp-autoprefixer node plugins for ease of use. I want to use gulp file with Magento instead of native grunt that Magento provides as a default build system for compilation of less files.Due to very slow nature of grunt, I decided to make own custom gulp workflow.
