Give minifiers an option to set the output path for files

Also makes linked js urls better in devel mode
This commit is contained in:
Slava Kim
2015-06-26 17:31:28 -07:00
parent fed3a5ec48
commit d06fe17e25
4 changed files with 24 additions and 6 deletions

View File

@@ -15,7 +15,8 @@ CssToolsMinifier.prototype.processFilesForTarget = function (files, mode) {
if (mode === 'development') {
files[0].addStylesheet({
data: merged.code,
sourceMap: merged.sourceMap
sourceMap: merged.sourceMap,
path: 'merged-stylesheets.css'
});
return;
}

View File

@@ -13,7 +13,8 @@ UglifyJSMinifier.prototype.processFilesForTarget = function (files, mode) {
files.forEach(function (file) {
file.addJavaScript({
data: file.getContentsAsBuffer(),
sourceMap: file.getSourceMap()
sourceMap: file.getSourceMap(),
path: file.getPathInPackage()
});
});
return;

View File

@@ -846,7 +846,13 @@ _.extend(Target.prototype, {
if (file.sourceMap) {
newFile.setSourceMap(file.sourceMap, '/');
}
newFile.setUrlToHash('.js');
if (file.path) {
newFile.setUrlFromRelPath(file.path);
newFile.targetPath = file.path;
} else {
newFile.setUrlToHash('.js');
}
return newFile;
});
@@ -998,7 +1004,13 @@ _.extend(ClientTarget.prototype, {
if (file.sourceMap) {
newFile.setSourceMap(file.sourceMap, '/');
}
newFile.setUrlToHash('.css', '?meteor_css_resource=true');
if (file.path) {
newFile.setUrlFromRelPath(file.path);
newFile.targetPath = file.path;
} else {
newFile.setUrlToHash('.css', '?meteor_css_resource=true');
}
return newFile;
});

View File

@@ -51,12 +51,14 @@ util.inherits(JsFile, InputFile);
_.extend(JsFile.prototype, {
// - data
// - sourceMap
// - path
// - hash?
addJavaScript: function (options) {
var self = this;
self._minifiedFiles.push({
data: options.data,
sourceMap: options.sourceMap
sourceMap: options.sourceMap,
path: options.path
});
}
});
@@ -70,12 +72,14 @@ util.inherits(CssFile, InputFile);
_.extend(CssFile.prototype, {
// - data
// - sourceMap
// - path
// - hash?
addStylesheet: function (options) {
var self = this;
self._minifiedFiles.push({
data: options.data,
sourceMap: options.sourceMap
sourceMap: options.sourceMap,
path: options.path
});
}
});