Merge pull request #11897 from meteor/always-minify-css-resource

Pass lazy css resources to minifier in development
This commit is contained in:
Filipe Névola
2022-02-10 02:01:17 +04:00
committed by GitHub
6 changed files with 11 additions and 5 deletions

View File

@@ -1120,8 +1120,7 @@ class Target {
// Takes a CssOutputResource and returns a string of minified CSS,
// or null to indicate no minification occurred.
minifyCssResource: (resource) => {
if (! minifiersByExt.css ||
minifyMode === "development") {
if (! minifiersByExt.css) {
// Indicates the caller should use the original resource.data
// without minification.
return null;

View File

@@ -1,4 +1,5 @@
<body>
<div class="production_css">Text for prod</div>
<div class="development_css">Text for devel</div>
<div class="minified_lazy">Text for imported</div>
</body>

View File

@@ -1,6 +1,8 @@
if (Meteor.isClient) {
require('./imports/imported.css');
Meteor.startup(function () {
['production_css', 'development_css'].forEach(cls => {
['production_css', 'development_css', 'minified_lazy'].forEach(cls => {
var color = getComputedStyle(document.querySelectorAll('.' + cls)[0]).color;
Meteor.call('print', cls + ': ' + color);
});

View File

@@ -0,0 +1,3 @@
.lazy-resource {
color: rgb(0, 256, 0);
}

View File

@@ -29,6 +29,7 @@ CustomMinifier.prototype.processFilesForBundle = function (files, options) {
data: contents
});
} else {
contents = contents.replace(/lazy-resource/g, 'minified_lazy');
file.addStylesheet({
data: contents
});
@@ -37,5 +38,3 @@ CustomMinifier.prototype.processFilesForBundle = function (files, options) {
Plugin.nudge();
});
};

View File

@@ -22,6 +22,7 @@ selftest.define('custom minifier - devel vs prod', function (options) {
run.match('production_css: rgb(255, 0, 0)');
run.match('development_css: rgb(0, 0, 0)');
run.match('minified_lazy: rgb(0, 255, 0)');
run.match('Message (client): production_js');
run.stop();
@@ -43,6 +44,7 @@ selftest.define('custom minifier - devel vs prod', function (options) {
run.match('production_css: rgb(0, 0, 0)');
run.match('development_css: rgb(255, 0, 0)');
run.match('minified_lazy: rgb(0, 255, 0)');
run.match('Message (client): development_js');
run.stop();