refactor build step

This commit is contained in:
Julien Bisconti 2018-03-18 15:01:47 +01:00
parent e9d09c35ee
commit c706acd1fa
2 changed files with 38 additions and 30 deletions

View File

@ -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,19 +38,14 @@ 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('');
critical
.generate({
inline: true,
base: 'website/',
src: 'index.merged.html',
dest: 'index.html',
css: 'website/style.css',
dimensions: [
const dimensions = [
{
height: 200,
width: 500
@ -59,18 +54,33 @@ const main = () => {
height: 900,
width: 1200
}
]
})
.then(() => {
];
const options = {
inline: true,
base,
src,
dest: 'index.html',
dimensions
};
return critical.generate(options);
};
const bundle = () => {
console.log('');
console.log('Bundling with Parcel.js');
console.log('');
new Parcel('website/index.html', {
name: 'build',
// publicURL: '/awesome-docker'
publicURL: '/'
}).bundle();
});
};
const main = async () => {
const { base, src } = includeReadme();
await css({ base, src });
bundle();
};
main();

View File

@ -6,8 +6,6 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta HTTP-EQUIV="REFRESH" content="0; url=https://awesome-docker.netlify.com">
<title>Awesome-docker</title>
<!-- <link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="critical.css"> -->
</head>
<body>
<p> <a href="https://awesome-docker.netlify.com/">We moved to a new place, click here to be redirected.</a></p>