Commit 5b216a78 authored by Philipp Nowinski's avatar Philipp Nowinski
Browse files

[FEATURE] add image dimensions module to css pipeline

parent bc02a66b
...@@ -13,6 +13,7 @@ const scss = require('postcss-scss'); ...@@ -13,6 +13,7 @@ const scss = require('postcss-scss');
const postcssSass = require('@csstools/postcss-sass'); const postcssSass = require('@csstools/postcss-sass');
const browserSync = require('browser-sync'); const browserSync = require('browser-sync');
const InlineSvg = require('@sgalinski/inline-svg'); const InlineSvg = require('@sgalinski/inline-svg');
const ImageDimensions = require('@sgalinski/image-dimensions');
/** /**
* The CSS task takes care of compiling Sass and running the CSS QA tasks * The CSS task takes care of compiling Sass and running the CSS QA tasks
...@@ -108,9 +109,11 @@ module.exports = class Css extends Task { ...@@ -108,9 +109,11 @@ module.exports = class Css extends Task {
precision: 8 precision: 8
}); });
let cssString = this._imageDimensions(compiledSass.css.toString());
let postProcessedCss = await postcss([ let postProcessedCss = await postcss([
autoprefixer autoprefixer
]).process(compiledSass.css, { ]).process(cssString, {
from: _input, from: _input,
to: _output, to: _output,
map: { map: {
...@@ -169,4 +172,15 @@ module.exports = class Css extends Task { ...@@ -169,4 +172,15 @@ module.exports = class Css extends Task {
return this._writeFile(partialFilePath, svgPartial); return this._writeFile(partialFilePath, svgPartial);
} }
/**
* Runs the whole CSS through the image dimensions module
*
* @param {String} _source The CSS as a string
*/
_imageDimensions(_source) {
let newSource = new ImageDimensions(_source, {
imageBasePath: this._getFullPath(this._config.directories.images)
}).process();
return newSource;
}
} }
...@@ -1683,6 +1683,14 @@ ...@@ -1683,6 +1683,14 @@
"resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.1.tgz", "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.1.tgz",
"integrity": "sha512-KU/VDjC5RwtDUZiz3d+DHXJF2lp5hB9dn552TXIyptj8SH1vXmR40mG0JgGq03IlYsOgGfcv8xrLpSQ0YUMQdA==" "integrity": "sha512-KU/VDjC5RwtDUZiz3d+DHXJF2lp5hB9dn552TXIyptj8SH1vXmR40mG0JgGq03IlYsOgGfcv8xrLpSQ0YUMQdA=="
}, },
"@sgalinski/image-dimensions": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@sgalinski/image-dimensions/-/image-dimensions-1.0.0.tgz",
"integrity": "sha512-FILK5GVgvKhNl1s4cMjkRZFXE4kbAC5RGUnf3KgJUxSJRkBeebPrcGpuXJNr2oni2oEc2Dln6GPyUGM/bmeQng==",
"requires": {
"image-size": "^0.6.3"
}
},
"@sgalinski/inline-svg": { "@sgalinski/inline-svg": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/@sgalinski/inline-svg/-/inline-svg-1.0.2.tgz", "resolved": "https://registry.npmjs.org/@sgalinski/inline-svg/-/inline-svg-1.0.2.tgz",
...@@ -6648,6 +6656,11 @@ ...@@ -6648,6 +6656,11 @@
"resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz",
"integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==" "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug=="
}, },
"image-size": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/image-size/-/image-size-0.6.3.tgz",
"integrity": "sha512-47xSUiQioGaB96nqtp5/q55m0aBQSQdyIloMOc/x+QVTDZLNmXE892IIDrJ0hM1A5vcNUDD5tDffkSP5lCaIIA=="
},
"imagemin": { "imagemin": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/imagemin/-/imagemin-6.0.0.tgz", "resolved": "https://registry.npmjs.org/imagemin/-/imagemin-6.0.0.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