Gulp is based on node, so the first step is to make sure you have the node environment installed, how to install it can go to the node website to see (https://nodejs.org/en/)
1.Global buttonGulp
Open the Node window input npm Install-g Gulp
After the global installation, go to the current directory to install the local installation
npm Install--save-dev Gulp
Use the command line when both the global and local project folders are installedgulp–v Check out the versionIf the version is the same, then it's best.
2. Plug-in installation
npm Install gulp-less--save-devNPM Install--save-dev gulp-less
NPM Install--save-dev Gulp-watch
After installing the plugin, we will see the file in the directory.
3.gulpfile.js Task Configuration
var gulp = require (' gulp '), less = require (' gulp-less '), watch = require (' Gulp-watch ');//Compile our less Gulp.task (' testless ', function () { gulp.src (' less/bootstrap.less '). Pipe (less ()) . Pipe (Gulp.dest (' css/');//output folder-main path}); Gulp.task (' Testwatch ', function () { gulp.watch (' less/*.less ', [' testless ']); When all less files change, call the Testless task});
After configuration, perform the Gulp Testwatch task for less monitoring, and when the less file is modified, the corresponding CSS file will change
Gulp-less plugin less file compiled into CSS