diff --git a/build.js b/build.js index 4dfb0fa..6bdfb9f 100644 --- a/build.js +++ b/build.js @@ -6,7 +6,7 @@ const critical = require('critical'); process.env.NODE_ENV = 'production'; -const main = () => { +const includeReadme = () => { const converter = new showdown.Converter({ omitExtraWLInCodeBlocks: true, simplifiedAutoLink: true, @@ -38,39 +38,49 @@ const main = () => { console.log('Writing index.html'); fs.writeFileSync('website/index.merged.html', $.html(), 'utf8'); + return { base: 'website/', src: 'index.merged.html' }; +}; +const css = ({ base, src }) => { console.log(''); console.log('Generating critical css above the fold'); console.log(''); + const dimensions = [ + { + height: 200, + width: 500 + }, + { + height: 900, + width: 1200 + } + ]; + const options = { + inline: true, + base, + src, + dest: 'index.html', + dimensions + }; - 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(''); + return critical.generate(options); +}; - new Parcel('website/index.html', { - name: 'build', - // publicURL: '/awesome-docker' - publicURL: '/' - }).bundle(); - }); +const bundle = () => { + console.log(''); + console.log('Bundling with Parcel.js'); + console.log(''); + + new Parcel('website/index.html', { + name: 'build', + publicURL: '/' + }).bundle(); +}; + +const main = async () => { + const { base, src } = includeReadme(); + await css({ base, src }); + bundle(); }; main(); diff --git a/index.html b/index.html index d072a82..572c816 100644 --- a/index.html +++ b/index.html @@ -6,8 +6,6 @@ Awesome-docker -

We moved to a new place, click here to be redirected.