Comments (1)
Ok I understand what was the issue.
TL/DR
SCSS file was encoded in UTF8-BOM. Switching to UTF8 (without BOM) resolved the issue.
Explanation
I created a single js file containing only the following line:
const sassExtract = require('sass-extract');
const renderedSass = sassExtract.renderSync({ file: "file.scss" });
console.log(renderedSass);
And I ran it with node test.js
(instead of doing it through webpack).
It allowed me to get the real error:
.\node_modules\gonzales-pe\lib\gonzales.js:812
throw new ParsingError(e, css);
^
Parsing error: Please check validity of the block starting from line #1
After fiddling with my scss file, I discover that it was stored in UTF8 with a BOM (a byte-order mask).
It seems that the Gonzales lib is choking on this byte.
Removing the BOM (i.e. storing as UTF8 only) resolve the issue.
Workaround
Workaround 1 : remove BOM of SCSS file
Workaround 2: read file with fs
, remove BOM and pass it directly to the lib:
const sassExtract = require('sass-extract');
const renderedSass = sassExtract.renderSync({
data: fs.readFileSync("file.scss", 'utf-8').replace(/^\uFEFF/, '')
});
console.log(renderedSass);
Solution taken from nodejs/node-v0.x-archive/issues/1918
Fix
I think the issue lies in the sass-extract library. Gonzales API expects a string.
The BOM is not part of the text. It is part of a file specification to identify an UTF8 encoded file.
Sass-extract should strip any BOM before passing it to the parser.
from sass-extract.
Related Issues (20)
- Support custom node-sass `importer` compileOption.
- Compact should not drop unit / new plugin needed HOT 3
- Parsing error while parsing Bulma SASS HOT 3
- DeprecationWarning: Module Chunks HOT 2
- Add a built in plugin for flexible transformation of output format HOT 1
- Raw css imports are not supported HOT 1
- Parse error in Bootstrap v4.1 HOT 1
- Prototype Pollution vulnerability of dependency HOT 3
- Function references assigned to variables throw errors HOT 1
- Importers - callback vs. Promise
- Unable to parse variables which contain a forward-slash `/`
- When calling the `findImportedPath` the `url` should be normalized to prevent issues on Windows
- Support for Dart Sass (possibility for using custom implementation) HOT 13
- Include doc comments HOT 2
- Sass plugin usage HOT 2
- Update node-sass peer dependency version? HOT 3
- Enable hex values to be capitalized HOT 1
- Look into nested map regression HOT 2
- Error when extracting variables with values containing calc function HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sass-extract.