ray-gulp-minify
v1.0.0
Published
gulp minify code
Downloads
1
Readme
ray-gulp-minify
usage
gulpfile.js
const gulp = require('gulp');
const terser = require('ray-gulp-minify');
function compile(){
return gulp.src('./src/**/*.js')
.pipe(terser())
.pipe(gulp.dest('lib'));
}
exports.default = compile;
// or
// gulp.task('default', compile);
ray-gulp-minify
参数项:
- minify 自定义压缩函数
- sourceMap terser source map
- terser options
terser Options
Terser 配置信息 terser#minify-options.
gulpfile.js
const gulp = require('gulp');
const terser = require('ray-gulp-minify');
function compile(){
return gulp.src('./src/**/*.js')
.pipe(terser({
keep_fnames: true,
mangle: false,
compress: {
drop_console: true
},
format: {
// ascii_only: true,
comments: 'all'
}
}))
.pipe(gulp.dest('lib'));
}
exports.default = compile;
// or
// gulp.task('default', compile);
使用自定义 minify 函数
gulpfile.js
const gulp = require('gulp');
const terser = require('terser');
const gulpTerser = require('ray-gulp-minify');
function compile(){
return gulp.src('./src/**/*.js')
.pipe(gulpTerser({
minify: terser.minify
}))
.pipe(gulp.dest('lib'));
}
exports.default = compile;
// or
// gulp.task('default', compile);
使用 sourcemaps
gulpfile.js
const gulp = require('gulp');
const sourcemaps = require('gulp-sourcemaps');
const terser = require('ray-gulp-minify');
function compile(){
return gulp.src('./src/**/*.js')
.pipe(sourcemaps.init())
.pipe(terser())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('lib'));
}
exports.default = compile;
// or
// gulp.task('default', compile);
License
MIT
author
ilex.h