Open simonwiles opened 3 years ago
When searching for config files (Babel, Postcss, ....), we stop once node_modules
is reached:
https://github.com/parcel-bundler/parcel/blob/67aefd83f8a32813aa86c904952d6ceb63eb235c/packages/transformers/postcss/src/loadConfig.js#L71-L74
So leaflet isn't even processed with your config file.
Same applies to babelrc: files from node_modules aren't processed with your project's Babel config.
Thanks, that's clearer now (I wasn't really sure where to look previously). What I really want to do is load the (preprocessed) CSS from my own .js
module using the bundle-text:
named pipeline (see https://github.com/simonwiles/parcel-postcss-image-inliner-example/blob/main/script.js -- but it's for web components so I'll be writing the CSS to the shadow dom). Do you see any way to achieve this other than "vendoring-in" the assets to my own source tree?
Edit: the CSS is being minified by Parcel (cssnano
?), so where is that config coming from? That's not part of the leaflet package.
At the moment no. We are no opposed to feature, but it should be opt in (so you'd somehow specify "yes, do apply my postcssrc to node_modules/leaflet/*
")...
the CSS is being minified by Parcel (cssnano?), so where is that config coming from? That's not part of the leaflet package.
The final bundle is minified, not the individual input assets. For optimizers/packagers, the config is read relative to the bundle output path.
Hope to deal with it soonοΌfile for node_modules not working when using postcss-pxtorem
π bug report
π Configuration (.babelrc, package.json, cli command)
package.json
index.html
π€ Expected Behavior
postcss-image-inliner
should be invoked on both css files.π― Current Behavior
postcss-image-inliner
is not invoked on the leaflet css. Note that the"strict": true
config passed topostcss-image-inliner
should make it fail if the assets can't be found, but theassetPaths
config is not the issue -- the plugin code is never called (confirmed by littering thepostcss-image-inliner
js withconsole.log
statements. It's invoked forstyles.css
but not for the leaflet css).π Possible Solution
The same assets compile as expected if they're simply copied out of
node_modules
, so is there something that's explicitly preventingnode_modules/**/*.css
being processed?π¦ Context
I'm writing some native web components, and I want to bundle all the needed assets into a single
.js
file, so I want to useimport leafletStyles from "bundle-text:leaflet/dist/leaflet.css";
and write theleafletStyles
into my component'sshadowDom
. But this problem surfaces even in with an html entrypoint and css included with<link>
tags.π» Code Sample
https://github.com/simonwiles/parcel-postcss-image-inliner-example
π Your Environment