Commit 03cbae33 authored by Philipp Nowinski's avatar Philipp Nowinski
Browse files

[FEATURE] add abovethefold task

parent ce4ead74
......@@ -16,6 +16,7 @@ const postcssSass = require('@csstools/postcss-sass');
const browserSync = require('browser-sync');
const InlineSvg = require('@sgalinski/inline-svg');
const ImageDimensions = require('@sgalinski/image-dimensions');
const { inlineSource } = require('inline-source');
/**
* The CSS task takes care of compiling Sass and running the CSS QA tasks
......@@ -37,6 +38,8 @@ module.exports = class Css extends Task {
steps.push(this._runCompile());
} else if (_subTask === 'svg') {
steps.push(this._svg());
} else if (_subTask === 'abovethefold') {
steps.push(this._abovethefold());
} else {
this._logTaskNotDefined(`css:${_subTask}`);
}
......@@ -55,7 +58,11 @@ module.exports = class Css extends Task {
*/
async _runCompile() {
return new Promise(async resolve => {
await this._svg();
let dependentTasks = [
this._svg(),
this._abovethefold()
];
await Promise.all(dependentTasks);
const files = await globby([
`${this._path}/${this._config.directories.sass}/*.scss`,
'!**/_*.scss'
......@@ -212,7 +219,7 @@ module.exports = class Css extends Task {
}
);
const partialFilePath = path.join(this._getFullPath(this._config.directories.sass), '_svg.scss');
this._logger.success(`ritten ${chalk.white(path.basename(partialFilePath))}`);
this._logger.success(`Written ${chalk.white(path.basename(partialFilePath))}`);
await this._writeFile(partialFilePath, svgPartial);
}
resolve();
......@@ -230,4 +237,23 @@ module.exports = class Css extends Task {
}).process();
return newSource;
}
/**
* Generates the abovethefold CSS
*/
async _abovethefold() {
return new Promise(async resolve => {
const filename = path.basename(this._config.abovethefold.template);
try {
let html = await inlineSource(this._config.abovethefold.template, {
compress: false
});
await this._writeFile(path.join(this._config.abovethefold.dest, filename), html);
} catch(_error) {
this._logger.error(_error);
}
this._logger.success(`Written ${chalk.white(path.basename(filename))}`);
resolve();
});
}
}
......@@ -3538,6 +3538,11 @@
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz",
"integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s="
},
"cookiejar": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz",
"integrity": "sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA=="
},
"copy-descriptor": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz",
......@@ -5413,6 +5418,11 @@
"mime-types": "^2.1.12"
}
},
"formidable": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.1.tgz",
"integrity": "sha512-Fs9VRguL0gqGHkXS5GQiMCr1VhZBxz0JnJs4JmMp/2jL18Fmbzvv7vOFRU+U8TBkHEE/CX1qDXzJplVULgsLeg=="
},
"fragment-cache": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz",
......@@ -6843,6 +6853,18 @@
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw=="
},
"inline-source": {
"version": "6.1.8",
"resolved": "https://registry.npmjs.org/inline-source/-/inline-source-6.1.8.tgz",
"integrity": "sha512-OkN55D/RMhf1mPYSb2LBaJI/lT79WiBoyKQYsaGSjaGpk5DyLhnTWsf74Ihpun22erVt+UU9SHSscAteoRxneQ==",
"requires": {
"csso": "~3.5.1",
"htmlparser2": "~3.9.2",
"superagent": "^3.8.3",
"svgo": "~1.0.5",
"uglify-js": "~3.4.6"
}
},
"inline-source-map": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz",
......@@ -8082,6 +8104,11 @@
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.2.2.tgz",
"integrity": "sha512-bgM8twH86rWni21thii6WCMQMRMmwqqdW3sGWi9IipnVAszdLXRjwDwAnyrVXo6DuP3AjRMMttZKUB48QWIFGg=="
},
"methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
},
"micromatch": {
"version": "3.1.10",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz",
......@@ -13578,6 +13605,33 @@
}
}
},
"superagent": {
"version": "3.8.3",
"resolved": "https://registry.npmjs.org/superagent/-/superagent-3.8.3.tgz",
"integrity": "sha512-GLQtLMCoEIK4eDv6OGtkOoSMt3D+oq0y3dsxMuYuDvaNUvuT8eFBuLmfR0iYYzHC1e8hpzC6ZsxbuP6DIalMFA==",
"requires": {
"component-emitter": "^1.2.0",
"cookiejar": "^2.1.0",
"debug": "^3.1.0",
"extend": "^3.0.0",
"form-data": "^2.3.1",
"formidable": "^1.2.0",
"methods": "^1.1.1",
"mime": "^1.4.1",
"qs": "^6.5.1",
"readable-stream": "^2.3.5"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
}
}
},
"supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
......@@ -14064,6 +14118,22 @@
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.17.tgz",
"integrity": "sha512-uRdSdu1oA1rncCQL7sCj8vSyZkgtL7faaw9Tc9rZ3mGgraQ7+Pdx7w5mnOSF3gw9ZNG6oc+KXfkon3bKuROm0g=="
},
"uglify-js": {
"version": "3.4.8",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.8.tgz",
"integrity": "sha512-WatYTD84gP/867bELqI2F/2xC9PQBETn/L+7RGq9MQOA/7yFBNvY1UwXqvtILeE6n0ITwBXxp34M0/o70dzj6A==",
"requires": {
"commander": "~2.17.1",
"source-map": "~0.6.1"
},
"dependencies": {
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
}
}
},
"uglifyify": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/uglifyify/-/uglifyify-5.0.1.tgz",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment