Open Froguard opened 6 years ago
Oh... Why do you need to use modconcat, if you know how to use gulp?
What about gulp-concat
?
You don't need any pool requests. See next test:
it('should replace parts of concated links in .html file ', function (cb) {
var stream = revCollector({
});
var fileCount = 0;
var revisionMap = {
"a.js": "a-17b72c16ec.js",
"b.js": "b-2c0d21e40c.js",
"c.js": "c-ffffffffff.js"
};
var htmlFileBody = '<html><head><script src="/js/??/com/a.js,/com/b.js,/com/c.js"></head><body><img src="cdn/image.gif" /></body></html>';
var htmlRevedFileBody = '<html><head><script src="/assets/js/com-mon-2c0d21e40c.js"><link rel="stylesheet" href="/assets/css/a-c-12345678.css" /></head><body><img src="cdn/image.gif" /></body></html>';
stream.write(new gutil.File({
path: 'rev/css/rev-manifest.json',
contents: new Buffer(JSON.stringify(revisionMap))
}));
stream.write(new gutil.File({
path: 'index.html',
contents: new Buffer(htmlFileBody)
}));
stream.on('data', function (file) {
var fpath = file.path;
var contents = file.contents.toString('utf8');
var ext = path.extname(file.path);
assert.equal(ext, '.html', 'Only html files should pass through the stream');
assert(
!/\/js\/\?\?\/com\/a\.js,\/com\/b\.js,\/com\/c\.js/.test(contents),
'The JS file name should be replaced'
);
assert(
/\/js\/\?\?\/com\/a-17b72c16ec\.js,\/com\/b-2c0d21e40c\.js,\/com\/c-ffffffffff\.js/.test(contents),
'The JS file name should be correct replaced'
);
fileCount++;
});
stream.on('end', function() {
assert.equal(fileCount, 1, 'Only one file should pass through the stream');
cb();
});
stream.end();
});
It works using gulp-rev-collector v1.2.2
how about the files with the same name,if rev by only name without necesary path.
发自网易邮箱大师 On 11/13/2017 19:31, Oleksandr Ovcharenko wrote:
You don't need any pool requests. See next test:
it('should replace parts of concated links in .html file ', function (cb) { var stream = revCollector({ }); var fileCount = 0; var revisionMap = { "a.js": "a-17b72c16ec.js", "b.js": "b-2c0d21e40c.js", "c.js": "c-ffffffffff.js" };
var htmlFileBody = '<html><head><script src="/js/??/com/a.js,/com/b.js,/com/c.js"></head><body><img src="cdn/image.gif" /></body></html>';
var htmlRevedFileBody = '<html><head><script src="/assets/js/com-mon-2c0d21e40c.js"><link rel="stylesheet" href="/assets/css/a-c-12345678.css" /></head><body><img src="cdn/image.gif" /></body></html>';
stream.write(new gutil.File({
path: 'rev/css/rev-manifest.json',
contents: new Buffer(JSON.stringify(revisionMap))
}));
stream.write(new gutil.File({
path: 'index.html',
contents: new Buffer(htmlFileBody)
}));
stream.on('data', function (file) {
var fpath = file.path;
var contents = file.contents.toString('utf8');
var ext = path.extname(file.path);
assert.equal(ext, '.html', 'Only html files should pass through the stream');
assert(
!/\/js\/\?\?\/com\/a\.js,\/com\/b\.js,\/com\/c\.js/.test(contents),
'The JS file name should be replaced'
);
assert(
/\/js\/\?\?\/com\/a-17b72c16ec\.js,\/com\/b-2c0d21e40c\.js,\/com\/c-ffffffffff\.js/.test(contents),
'The JS file name should be correct replaced'
);
fileCount++;
});
stream.on('end', function() {
assert.equal(fileCount, 1, 'Only one file should pass through the stream');
cb();
});
stream.end();
});
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
neural network will help You in this case.
var revisionMap = {
"a.js": "a-17b72c16ec.js",
"a.js": "a-aaaaaaaaaa.js",
"b.js": "b-2c0d21e40c.js",
"c.js": "c-ffffffffff.js"
};
console.log(revisionMap); - ???
index.html
Example:
origin:
/js/??/com/a.js,/com/b.js,/com/c.js
after:/js/??/com/a-[revcode].js,/com/b-[revcode].js,/com/c-[revcode].js
gulpfile.js
You can see PR43 :smiley:
more about concat static asserts : nginx-http-concat