parcel-bundler / lightningcss

An extremely fast CSS parser, transformer, bundler, and minifier written in Rust.
https://lightningcss.dev
Mozilla Public License 2.0
6.45k stars 186 forks source link

CLI sourcemap option emits useless sourceMappingURL #609

Open Earlopain opened 1 year ago

Earlopain commented 1 year ago

With LightningCSS I have to do some gymanstics to produce a usable sourcemap. The command lightningcss ./app/stylesheet/application.css -o ./public/build/application.css --sourcemap adds /*# sourceMappingURL=./public/build/application.css.map */ as a comment and makes it impossible for the browser to load.

I have to run cd public/build && lightningcss ../../app/stylesheet/application.css -o application.css --sourcemap to produce a sourcemap comment that is actually usable. /*# sourceMappingURL=application.css.map */

The sourcemap file as always saved in the same folder as the output is. LightningCSS should just set the filename and omit the path that the outfile might be part of. This is also the behaviour that sass is doing.

Using the filename from out_file here and writing that into the code should do it. I did try doing that myself but I haven't done rust before and am unable to cope with all the string types. https://github.com/parcel-bundler/lightningcss/blob/eb280df5c135e647b05a409017ecb3ce6e337494/src/main.rs#L245-L251

trymeouteh commented 2 months ago

https://github.com/parcel-bundler/lightningcss/issues/794