Answer the question
In order to leave comments, you need to log in
How to issue a task in gulp to generate critical CSS at given URLs using the critical plugin?
Uses the npm critical module to generate critical CSS. However, html files for it are downloaded manually:
gulp.task("criticalCss", function() {
var critical = require('critical'),
name = "ProductProductCommon";
critical.generate({
base: 'uncss_ignore/',
src: object + '.html',
dest: 'css/critical/mobile' + object + '.css',
minify: true,
dimensions: [{
width: 360,
height: 640
}],
});
});
[{name: "Product", url: "site.com/product/2345.html"},
{name: "Catalog", url: "site.com/catalog.html"}]
module.exports = function(gulp, plugins) {
return function () {
var critical = require('critical'),
object = "ProductProductCommon",
settings = require("./settings.js");
critical.generate({
src: settings.base_url,
dest: './' + object + '.css',
minify: true,
dimensions: [{
width: 360,
height: 640
}],
});
};
}
module.exports = function(gulp, plugins) {
return function () {
var critical = require('critical'),
settings = require("./settings.js"),
urls = [
{name: "home", url:""},
{name: "product", url:"palatki/34174.html"},
{name: "catalog", url:"palatki.html"},
{name: "o_nas", url:"o_nas.html"},
{name: "dostavka", url:"dostavka.html"},
{name: "oplata", url:"oplata.html"},
{name: "basket", url:"basket.html"},
{name: "contacts", url:"contacts.html"}
];
urls.forEach(function(entry){
critical.generate({
src: settings.base_url + entry.url,
dest: settings.dest_folder + entry.name + '.css',
minify: true,
dimensions: settings.dimensions
});
});
};
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question