fd-gulp-jsmin
minify js files.
Last updated 5 years ago by fangdeng .
ISC · Repository · Original npm · Tarball · package.json
$ cnpm install fd-gulp-jsmin 
SYNC missed versions from official npm registry.

fd-gulp-jsmin任务是根据指定的书写规则来对js文件进行压缩,此插件使用的是yuicompressor-2.4.7.jar压缩工具包。

用法

jsMin(srcDir [,opt]);

例子

var gulp = require('gulp');
var jsMin = require('fd-gulp-jsmin');

gulp.task('jsMin', function() {
	gulp.src('D:/wwwroot/workspace/fd-gulp-jsconcat/test/style_test/**/*.js')
		.pipe(jsMin('D:/wwwroot/workspace/fd-gulp-jsmin/test/style_test'))
		.pipe(gulp.dest('./output'));
});

合并规则

  • 默认不对代码进行压缩
  • 开启压缩以及配置压缩的方式是在 js 的注释中写入相应的控制语句
  • 开启压缩需要写入:!!cmd:compress=true
  • (可选)把中文转成 unicode 的形式,写入: !!cmd:conv2unicode=true
  • (可选)使用 yui compressor 的 js 压缩选项: !!cmd:jsCompressOpt=["$option"] $option 为 yui compressor 支持的三种压缩模式任意之一
  • 如果只想使用 yui 的默认压缩,请不要写入 !!cmd:jsCompressOpt 这一项
  • 只有开启了压缩,js 的压缩选项,中文转 unicode 这些配置才会生效
  • 由于压缩比较耗时,所以不要对不会被页面直接引入的文件配置压缩,建议只对 merge 文件配置压缩

js 压缩选项功能 --nomunge Minify only. Do not obfuscate local symbols.

--preserve-semi Preserve unnecessary semicolons (such as right before a '}') This option is useful when compressed code has to be run through JSLint (which is the case of YUI for example)

--disable-optimizations Disable all the built-in micro optimizations.

Current Tags

  • 0.0.2                                ...           latest (5 years ago)

2 Versions

  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 5
Dependencies (4)
Dev Dependencies (3)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |