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,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();

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>