Gulp--less

Source: Internet
Author: User

Summary:

Previously shared some less is the method, including in grunt, today under sharing with gulp to compile the less file. First need to install Gulp, how to install please read the article.

To install the plugin:

Gulp compile less uses the Gulp-less module, so the Package.json is as follows:

{    "name": "Gulp-less",    "version": "1.0.0",    "private": True,    "description": "Gulp-less",    "main" : "Gulpfile.js",    "dependencies": {},    "Devdependencies": {        "gulp": "~3.5.6",        "gulp-less": "1.3.6",        "Gulp-minify-css": "~0.3.0",        "Gulp-concat": "~2.4.0",        "Gulp-rename": "~1.2.0"    },    " Keywords ": [" Gulp "," gulp-less "," less "],    " author ":" ",    " license ":" ISC "}

After installation, create a new gulpfile.js, file structure:

Gulpfile.js

Public

?| -->?less

Gulpfile.js:

varGulp = require (' Gulp ')), less= Require (' gulp-less '), Concat= Require (' Gulp-concat '), rename= Require (' Gulp-rename '), Minifycss= Require (' Gulp-minify-css '); Gulp.task (' Build-less ',function() {GULP.SRC ('./public/less/*.less '). Pipe (Less ({compress:true}). On (' Error ',function(e) {console.log (e);}) . Pipe (Gulp.dest ('./public/css/'));});//merging, compressing, renaming CSSGulp.task (' Min-styles ', [' build-less '),function() {GULP.SRC (['./public/css/*.css ']). Pipe (Concat (' All.css '))//merge files to All.css. Pipe (Gulp.dest ('./public/css/'))//Output All.css file. Pipe (rename ({suffix: '. Min '}))//Rename all.css to All.min.css. Pipe (Minifycss ())//Compress CSS Files. Pipe (Gulp.dest ('./public/css/'));//Output All.min.css}); Gulp.task (' Develop ',function() {Gulp.watch ('./public/less/*.less ', [' build-less ', ' min-styles ']);});

In the current directory, execute through the command window

Gulp Build-less: You will find in the public/css/directory that the less file under the less directory is compiled into the corresponding CSS file.

Gulp Min-styles: The All.css and all.min.css files will be exported in the CSS directory.

Gulp Develop: All less files are monitored, and when less files are changed, build-less and Min-styles are executed

Gulp--less

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.