Commit af7694bf authored by Philipp Nowinski's avatar Philipp Nowinski
Browse files

[BUGFIX][WIP] current state of the sourcemap fix

parent 8aa29355
......@@ -10,6 +10,7 @@ const chalk = require('chalk');
const stylelint = require('stylelint');
const reporter = require('postcss-reporter');
const scss = require('postcss-scss');
const postcssSass = require('@csstools/postcss-sass');
/**
* The CSS task takes care of compiling Sass and running the CSS QA tasks
......@@ -47,8 +48,11 @@ module.exports = class Css extends Task {
*
* @param {String} _fileName The name of the input file
*/
_getOutputPath(_fileName) {
let fileName = path.basename(_fileName).replace('.scss', '.css');
_getOutputPath(_fileName) {
let newSuffix = this._settings.css.pipeline.renameToDotMin
? '.min.css'
: '.css';
let fileName = path.basename(_fileName).replace('.scss', newSuffix);
return this._getFullPath(`${this._settings.directories.css}/${fileName}`);
}
......@@ -72,27 +76,37 @@ module.exports = class Css extends Task {
const render = util.promisify(sass.render);
let result;
const sourceMapPath = this._getSourceMapsPath(_output);
try {
result = await render({
file: _input,
outputStyle: 'compressed',
outFile: _output,
sourceMap: sourceMapPath
});
} catch(_error) {
this._logger.error(_error.stack);
}
// try {
// result = await render({
// file: _input,
// outFile: _output,
// outputStyle: 'expanded',
// sourceMap: true,
// sourceMapEmbed: true,
// precision: 8
// });
// } catch(_error) {
// this._logger.error(_error.stack);
// }
let css = await postcss([
require('@csstools/postcss-sass')(/* node-sass options */)
], {
syntax: scss
}).process(
fs.readFileSync(_input, 'utf-8')
);
let css = await postcss([autoprefixer]).process(result.css, {from: _input});
// let css = result;
try {
await this._writeFile(_output, css);
await this._writeFile(sourceMapPath, result.map);
await this._writeFile(_output, css.css);
await this._writeFile(sourceMapPath, css.map);
} catch (_error) {
return this._logger.error(_error.stack);
}
this._logger.success(`Written ${chalk.white(path.basename(_input))}`)
this._logger.success(`Written ${chalk.white(path.basename(_output))}`)
this._logger.success(`Written ${chalk.white(path.basename(sourceMapPath))}`)
}
......
......@@ -164,6 +164,39 @@
"to-fast-properties": "^2.0.0"
}
},
"@csstools/postcss-sass": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@csstools/postcss-sass/-/postcss-sass-2.0.0.tgz",
"integrity": "sha512-vxM3iX7TVKdzxNf7EZhbF5xufh7u9ClVsz8vKW2ejWtUiLCQdCCkARz6beTw2V+Pkqhs66kTC9eDguF26frdtQ==",
"requires": {
"@csstools/sass-import-resolve": "^1.0",
"node-sass": "^4.7",
"postcss": "^6.0",
"source-map": "^0.6"
},
"dependencies": {
"postcss": {
"version": "6.0.23",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-6.0.23.tgz",
"integrity": "sha512-soOk1h6J3VMTZtVeVpv15/Hpdl2cBLX3CAw4TAbkpTJiNPk9YP/zWcD1ND+xEtvyuuvKzbxliTOIyvkSeSJ6ag==",
"requires": {
"chalk": "^2.4.1",
"source-map": "^0.6.1",
"supports-color": "^5.4.0"
}
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
}
}
},
"@csstools/sass-import-resolve": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@csstools/sass-import-resolve/-/sass-import-resolve-1.0.0.tgz",
"integrity": "sha512-pH4KCsbtBLLe7eqUrw8brcuFO8IZlN36JjdKlOublibVdAIPHCzEnpBWOVUXK5sCf+DpBi8ZtuWtjF0srybdeA=="
},
"@mrmlnc/readdir-enhanced": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz",
......
......@@ -15,6 +15,7 @@
"node": "~10.9.0"
},
"dependencies": {
"@csstools/postcss-sass": "^2.0.0",
"autoprefixer": "^9.1.3",
"chalk": "^2.4.1",
"freedesktop-notifications": "^1.2.3",
......
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