Simple gulpfile.js parameter configuration

Source: Internet
Author: User

Here Gulp installation and module installation I won't mention it, just write some configuration functions.

For example

/**
* Created by Yumeiqiang on 16/7/26.
*/
var gulp = require (' gulp ');
var uglify = require (' gulp-uglify ');//Get uglify module (for compressing JS)
var minifycss = require (' gulp-minify-css ');//Get MINIFY-CSS module (for compressing CSS)
var sass = require (' Gulp-ruby-sass ');
var htmlminify = require ("gulp-html-minify");
Compressing JS files
Start this task using Gulp script at the command line
Gulp.task (' Script ', function () {
1. Find File
GULP.SRC (' Vue/src/js/*.js ')
2. Compress files
. Pipe (Uglify ())
3. Save the compressed file
. Pipe (Gulp.dest (' Vue/dist/js '))
})
Compress CSS Files
Start this task at the command line using gulp CSS
Gulp.task (' CSS ', function () {
1. Find File
GULP.SRC (' Vue/src/css/*.css ')
2. Compress files
. Pipe (Minifycss ())
3. Save As compressed file
. Pipe (Gulp.dest (' vue/dist/css '))
})

Start this task at the command line using Gulp Auto
Gulp.task (' Auto ', function () {
Listen for file modification, execute CSS task when file is modified
Gulp.watch (' css/*.css ', [' CSS '])
});

Define default tasks using Gulp.task (' default ')
To start a CSS task and auto task at the command line using Gulp
Compiling sass
Start this task by entering Gulp Sass on the command line
Gulp.task (' sass ', function () {
return sass (' Vue/src/css/hm.scss ')
. On (' Error ', Sass.logerror)
. Pipe (Gulp.dest (' vue/src/css '));
});
Compress HTML
Gulp.task (' build-html ', function () {
Return gulp.src ("vue/website/activity/spike/spike.html")
. Pipe (Htmlminify ())
. Pipe (Gulp.dest ("vue/website/minify/spike.html"))
});
Start this task at the command line using Gulp Auto
Gulp.task (' Auto ', function () {
Listen for file modification, perform images task when file is modified
Gulp.watch (' vue/src/css/hm.scss ', [' sass '])
});

Define default tasks using Gulp.task (' default ')
Use Gulp to start sass tasks and auto tasks at the command line
Gulp.task (' Default ', [' sass ', ' auto '])
Gulp.task (' Default ', [' css ', ' auto ', ' script '])

Simple gulpfile.js parameter configuration

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.