Open adrienharnay opened 1 week ago
@adrienharnay sass doesn't know how to work with JSN files, so this behavior is logical, you need a custom resolver
That the // No need to pass loadPaths, because modern API handle them itself comment is not 100% right.
It works, but only for sass
/scss
That without restrictions: [/.(((sa|sc|c)ss)|json)$/i],, the JSON file won't be picked up by the webpack resolver and thus it won't load.
It's expected because sass
doesn't know how to parse JSON
file
That we need to re-implement our importer logic in the sass-loader load function because it won't call our importer (?).
What do you mean?
Just use:
{
loader: "sass-loader",
options: {
sourceMap: true,
sassOptions: {
loadPaths: [path.resolve(__dirname, "./src")],
importer: [
SassJSONImporter({
includePaths: path.resolve(__dirname, "./src"),
})
],
},
},
},
Modification Proposal
I believe there are some quirks in the current
importer
implementation that limit possible use cases. One of these use cases is to import JSON files withsass
orembedded-sass
implementations.Expected Behavior / Situation
Here is a minimal reproduction with steps to understand the limitations and changes needed to make the importer work.
From the README:
// No need to pass
loadPaths, because modern API handle them itself
comment is not 100% right.restrictions: [/\.(((sa|sc|c)ss)|json)$/i],
, the JSON file won't be picked up by the webpack resolver and thus it won't load.sass-loader
load
function because it won't call our importer (?).I remain available to exchange on the topic, having spent a few hours browsing and debugging the code.
Please paste the results of
npx webpack-cli info
here, and mention other relevant informationThanks in advance!