mirror of
https://github.com/veggiemonk/awesome-docker.git
synced 2025-04-19 07:28:05 +02:00
critical css inlined
This commit is contained in:
parent
606cb04513
commit
d45cec0294
7 changed files with 102 additions and 1237 deletions
99
build.js
99
build.js
|
@ -2,46 +2,75 @@ const fs = require('fs');
|
|||
const showdown = require('showdown');
|
||||
const cheerio = require('cheerio');
|
||||
const Parcel = require('parcel-bundler');
|
||||
const critical = require('critical');
|
||||
|
||||
process.env.NODE_ENV = 'production';
|
||||
|
||||
const converter = new showdown.Converter({
|
||||
omitExtraWLInCodeBlocks: true,
|
||||
simplifiedAutoLink: true,
|
||||
excludeTrailingPunctuationFromURLs: true,
|
||||
literalMidWordUnderscores: true,
|
||||
strikethrough: true,
|
||||
tables: true,
|
||||
tablesHeaderId: true,
|
||||
ghCodeBlocks: true,
|
||||
tasklists: true,
|
||||
disableForced4SpacesIndentedSublists: true,
|
||||
simpleLineBreaks: true,
|
||||
requireSpaceBeforeHeadingText: true,
|
||||
ghCompatibleHeaderId: true,
|
||||
ghMentions: true,
|
||||
backslashEscapesHTMLTags: true,
|
||||
emoji: true,
|
||||
splitAdjacentBlockquotes: true
|
||||
});
|
||||
// converter.setFlavor('github');
|
||||
const main = () => {
|
||||
const converter = new showdown.Converter({
|
||||
omitExtraWLInCodeBlocks: true,
|
||||
simplifiedAutoLink: true,
|
||||
excludeTrailingPunctuationFromURLs: true,
|
||||
literalMidWordUnderscores: true,
|
||||
strikethrough: true,
|
||||
tables: true,
|
||||
tablesHeaderId: true,
|
||||
ghCodeBlocks: true,
|
||||
tasklists: true,
|
||||
disableForced4SpacesIndentedSublists: true,
|
||||
simpleLineBreaks: true,
|
||||
requireSpaceBeforeHeadingText: true,
|
||||
ghCompatibleHeaderId: true,
|
||||
ghMentions: true,
|
||||
backslashEscapesHTMLTags: true,
|
||||
emoji: true,
|
||||
splitAdjacentBlockquotes: true
|
||||
});
|
||||
// converter.setFlavor('github');
|
||||
|
||||
console.log('Loading files...');
|
||||
const index = fs.readFileSync('website/index.tmpl', 'utf8');
|
||||
const readme = fs.readFileSync('README.md', 'utf8');
|
||||
console.log('Loading files...');
|
||||
const index = fs.readFileSync('website/index.tmpl.html', 'utf8');
|
||||
const readme = fs.readFileSync('README.md', 'utf8');
|
||||
|
||||
console.log('Merging files...');
|
||||
const $ = cheerio.load(index);
|
||||
$('#md').append(converter.makeHtml(readme));
|
||||
console.log('Merging files...');
|
||||
const $ = cheerio.load(index);
|
||||
$('#md').append(converter.makeHtml(readme));
|
||||
|
||||
console.log('Writing index.html');
|
||||
fs.writeFileSync('website/index.html', $.html(), 'utf8');
|
||||
console.log('Writing index.html');
|
||||
fs.writeFileSync('website/index.merged.html', $.html(), 'utf8');
|
||||
|
||||
console.log('Bundling with Parcel.js');
|
||||
console.log('');
|
||||
console.log('');
|
||||
console.log('Generating critical css above the fold');
|
||||
console.log('');
|
||||
|
||||
new Parcel('website/index.html', {
|
||||
name: 'build',
|
||||
// publicURL: '/awesome-docker'
|
||||
publicURL: '/'
|
||||
}).bundle();
|
||||
critical
|
||||
.generate({
|
||||
inline: true,
|
||||
base: 'website/',
|
||||
src: 'index.merged.html',
|
||||
dest: 'index.html',
|
||||
css: 'website/style.css',
|
||||
dimensions: [
|
||||
{
|
||||
height: 200,
|
||||
width: 500
|
||||
},
|
||||
{
|
||||
height: 900,
|
||||
width: 1200
|
||||
}
|
||||
]
|
||||
})
|
||||
.then(() => {
|
||||
console.log('Bundling with Parcel.js');
|
||||
console.log('');
|
||||
|
||||
new Parcel('website/index.html', {
|
||||
name: 'build',
|
||||
// publicURL: '/awesome-docker'
|
||||
publicURL: '/'
|
||||
}).bundle();
|
||||
});
|
||||
};
|
||||
|
||||
main();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue