javascript 最小的Gulp设置w / LESS + autoprefix / compress,JS + jshint / minify
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 最小的Gulp设置w / LESS + autoprefix / compress,JS + jshint / minify相关的知识,希望对你有一定的参考价值。
{
"name": "tam-gulp",
"version": "0.0.1",
"devDependencies": {
"gulp": "*",
"jshint": "*",
"gulp-sourcemaps": "*",
"gulp-jshint": "*",
"gulp-less": "*",
"gulp-rename": "*",
"gulp-uglify": "*",
"gulp-util": "*",
"less-plugin-autoprefix": "*",
"less-plugin-clean-css": "*"
}
}
var gulp = require('gulp'),
sourcemaps = require('gulp-sourcemaps'),
uglify = require("gulp-uglify"),
jshint = require("gulp-jshint"),
rename = require("gulp-rename"),
less = require("gulp-less"),
LessPluginCleanCSS = require('less-plugin-clean-css'),
cleancss = new LessPluginCleanCSS({ advanced: true }),
LessPluginAutoPrefix = require('less-plugin-autoprefix'),
autoprefixer = new LessPluginAutoPrefix({ browsers: ["last 2 versions"] });
// JS
gulp.task('js', function () {
gulp.src(['public/assets/js/**/*.js', '!public/assets/js/**/*.min.js'])
.pipe(sourcemaps.init())
.pipe(jshint())
.pipe(jshint.reporter())
.pipe(uglify().on('error', function(err){ console.log(err.message); }))
.pipe(rename({ suffix: ".min" }))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest('public/assets/js'));
});
// Less
gulp.task('less', function () {
gulp.src('public/assets/less/style.less')
.pipe(less({
plugins: [autoprefixer, cleancss]
}).on('error', function(err){ console.log(err.message); }))
.pipe(gulp.dest('public/assets/css'));
});
// Watchers
gulp.task('watch', function () {
gulp.watch(['public/assets/js/**/*.js', '!public/assets/js/**/*.min.js'], ['js']);
gulp.watch(['public/assets/less/**/*'], ['less']);
});
gulp.task('default', ['watch']);
以上是关于javascript 最小的Gulp设置w / LESS + autoprefix / compress,JS + jshint / minify的主要内容,如果未能解决你的问题,请参考以下文章
javascript 适用于WordPress的Gulp设置代码段也可用于前端开发
使用gulp将移动端xp转为rem
基于 Laravel 开发博客应用系列 —— 从测试开始:使用Gulp实现自动化测试
W 艺燃艺爆炸|纽约The Hole画廊——“Gulp”
2-3 感知机梯度下降法的推导过程
最小二乘法和岭回归