Created
August 23, 2019 17:47
-
-
Save stanleybz/072af59682b2a877435592a16dd8c285 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const critical = require('critical'); | |
function generateCCSS(inputURL) { | |
const is_mobile = false; | |
var ccss_options = { | |
src: inputURL, | |
ignore: { | |
atrule: ['@font-face', '@import'], | |
}, | |
minify: false, | |
}; | |
ccss_options.userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'; | |
ccss_options.width = is_mobile ? 479 : 1366; | |
ccss_options.height = is_mobile ? 812 : 768; | |
try { | |
critical.generate(ccss_options).then(criticalCss => { | |
console.log(criticalCss.css); | |
console.log('success') | |
}).catch(err => { | |
console.log('err1', err); | |
}); | |
} catch (err) { | |
console.log('err2', err); | |
} | |
} | |
const inputURL = process.argv[2]; | |
generateCCSS(inputURL); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment