mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Put the concatenation part of minification to minifier plugins
This commit is contained in:
@@ -8,6 +8,7 @@ Plugin.registerMinifier({
|
||||
function CssToolsMinifier () {};
|
||||
|
||||
CssToolsMinifier.prototype.processFilesForTarget = function (files) {
|
||||
CssTools.blessCss();
|
||||
files.forEach(function (file) {
|
||||
file.addStylesheet({
|
||||
data: CssTools.minifyCss(file.getContentsAsString())
|
||||
|
||||
@@ -17,12 +17,13 @@ UglifyJSMinifier.prototype.processFilesForTarget = function (files) {
|
||||
}
|
||||
};
|
||||
|
||||
var allJs = '';
|
||||
files.forEach(function (file) {
|
||||
file.addJavaScript({
|
||||
data: UglifyJSMinify(
|
||||
file.getContentsAsString(), minifyOptions).code
|
||||
});
|
||||
allJs += UglifyJSMinify(file.getContentsAsString(), minifyOptions).code;
|
||||
allJs += '\n\n';
|
||||
});
|
||||
|
||||
files[0].addJavaScript({ data: allJs });
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -842,10 +842,17 @@ _.extend(Target.prototype, {
|
||||
}
|
||||
});
|
||||
|
||||
var allJs = _.pluck(sources, '_minified').join("\n\n");
|
||||
self.js = _.flatten(_.map(sources, function (source) {
|
||||
return _.map(source._minifiedFiles, function (file) {
|
||||
var newFile = new File({
|
||||
info: 'minified js',
|
||||
data: new Buffer(file.data, 'utf8')
|
||||
});
|
||||
newFile.setUrlToHash('.js');
|
||||
|
||||
self.js = [new File({ info: 'minified js', data: new Buffer(allJs, 'utf8') })];
|
||||
self.js[0].setUrlToHash('.js');
|
||||
return newFile;
|
||||
});
|
||||
}));
|
||||
}),
|
||||
|
||||
// Add a Cordova plugin dependency to the target. If the same plugin
|
||||
@@ -1025,10 +1032,17 @@ _.extend(ClientTarget.prototype, {
|
||||
}
|
||||
});
|
||||
|
||||
var allCss = _.pluck(sources, '_minified').join("\n");
|
||||
self.css = _.flatten(_.map(sources, function (source) {
|
||||
return _.map(source._minifiedFiles, function (file) {
|
||||
var newFile = new File({
|
||||
info: 'minified css',
|
||||
data: new Buffer(file.data, 'utf8')
|
||||
});
|
||||
newFile.setUrlToHash('.css', '?meteor_css_resource=true');
|
||||
|
||||
self.css = [new File({ info: 'minified css', data: new Buffer(allCss, 'utf8') })];
|
||||
self.css[0].setUrlToHash(".css", "?meteor_css_resource=true");
|
||||
return newFile;
|
||||
});
|
||||
}));
|
||||
}),
|
||||
|
||||
// Output the finished target to disk
|
||||
|
||||
@@ -7,7 +7,7 @@ var InputFile = exports.InputFile = function (source) {
|
||||
|
||||
var self = this;
|
||||
self._source = source;
|
||||
self._minified = source.contents('utf8');
|
||||
self._minifiedFiles = [];
|
||||
};
|
||||
|
||||
util.inherits(InputFile, buildPluginModule.InputFile);
|
||||
@@ -35,7 +35,9 @@ _.extend(JsFile.prototype, {
|
||||
// - hash?
|
||||
addJavaScript: function (options) {
|
||||
var self = this;
|
||||
self._minified = options.data.toString('utf8');
|
||||
self._minifiedFiles.push({
|
||||
data: options.data.toString('utf8')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -50,7 +52,9 @@ _.extend(CssFile.prototype, {
|
||||
// - hash?
|
||||
addStylesheet: function (options) {
|
||||
var self = this;
|
||||
self._minified = options.data.toString('utf8');
|
||||
self._minifiedFiles.push({
|
||||
data: options.data.toString('utf8')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user