gulp rev manifest 添加目录前缀

2018-04-03 15:13:11 浏览数 (1)

gulp-rev 生成的manifest默认为:

代码语言:javascript复制
"index.css": "index.css?v=04aff97a7b",

  为避免同名文件覆盖版本号,对替换的路径增加一级目录,如下

代码语言:javascript复制
"css/index.css": "css/index.css?v=04aff97a7b",

修改gulp-rev下index.js,

123行增加manifest传入参数:

代码语言:javascript复制
opts = objectAssign({
		path: 'rev-manifest.json',
		merge: false,
		// Apply the default JSON transformer.
		// The user can pass in his on transformer if he wants. The only requirement is that it should
		// support 'parse' and 'stringify' methods.
		transformer: JSON,
		pwd_base: '' //增加一级目录
	}, opts, pth);

146行增加:

代码语言:javascript复制
originalFile = opts.pwd_base   originalFile;

  gulp文件配置增加目录:

代码语言:javascript复制
.pipe(rev.manifest({ pwd_base: 'css/' }))

0 人点赞