gulp 最新使用

安装

node js 肯定要先安装,还不会的,自行百度

npm install --global gulp-cli
npm init

安装插件

npm install gulp-less
npm install gulp-csso
npm install gulp-concat

使用

创建gulpfile.js文件

const {src, dest, parallel, watch} = require('gulp');

const less = require('gulp-less');
const minifyCSS = require('gulp-csso');
const concat = require('gulp-concat');

const less_dir = './less';
const dest_dir = '../css/';


function less_css() {
    return src(less_dir + '/ui.less', {sourcemaps: true})
        .pipe(less())
        .pipe(minifyCSS())
        .pipe(dest(dest_dir))
}

function js() {
    return src('client/javascript/*.js', {sourcemaps: true})
        .pipe(concat('app.min.js'))
        .pipe(dest('build/js', {sourcemaps: true}))
}


watch([less_dir + '/*.less'], parallel(less_css));

exports.js = js;
exports.less_css = less_css;
exports.default = parallel(less_css);

你可能感兴趣的:(gulp 最新使用)