parcel: [parcel 2] does not minify css imported with `bundle-text:`
๐ bug report
When importing css as string into javascript with bundle-text:
as described here the css does not get processed at all.
๐ Configuration (.babelrc, package.json, cli command)
Cli command:
npm run build
Please see attached .zip file for the rest.
๐ค Expected Behavior
The inlined css code should be minified and look like this:
!function(){var n,e=(n="body{background:red}")&&n.__esModule?n.default:n;const d=document.createElement("style"),t=()=>document.body.append(d);d.type="text/css",d.append(e),document.body?t():window.addEventListener("DOMContentLoaded",t)}();
๐ฏ Current Behavior
The inlined css code looks just like before.
!function(){var n,e=(n="/* THIS IS A COMMENT*/\n\n\n/*\nh\ne\nr\ne\n\nh\ne\nr\ne\n\n\nb\ne\n\nw\nh\ni\nt\ne\ns\np\na\nc\ne\ns\n*/\n\n\n\n\n\n\n\n\nbody {\n background: red;\n}\n\n")&&n.__esModule?n.default:n;const d=document.createElement("style"),t=()=>document.body.append(d);d.type="text/css",d.append(e),document.body?t():window.addEventListener("DOMContentLoaded",t)}();
๐ Possible Solution
Process the css
๐ฆ Context
https://github.com/parcel-bundler/parcel/discussions/5751
๐ป Code Sample
๐ Your Environment
Software | Version(s) |
---|---|
Parcel | 2.0.0-nightly.562+fbca3a93 |
Node | v15.6.0 |
npm/Yarn | 7.4.0 |
Operating System | macOS High Sierra 10.13.6 |
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (14 by maintainers)
This should be fixed in #6379. Basically it will only try to match pipelines that actually exist in the optimizers config. See https://github.com/parcel-bundler/parcel/pull/6379/commits/a2a7da176c482353ea192bbe50cd75c38e2e2407. Does this logic make sense to you?
Yeah. You still shouldnโt have to actually list out all pipelines in the optimizers object thoughโฆ
-> https://github.com/parcel-bundler/parcel/issues/5765
We should probably add a pure comment to the interop call, Terser removes everything here:
Would that fix your case?