Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement sourcemaps for CSS #1824

Closed
ocoka opened this issue Jul 30, 2018 · 8 comments
Closed

Implement sourcemaps for CSS #1824

ocoka opened this issue Jul 30, 2018 · 8 comments

Comments

@ocoka
Copy link

ocoka commented Jul 30, 2018

πŸ™‹β€β™€οΈ Feature request

Hello, I have some problem with parcel-bundler@1.9.7, - there is no sourcemap emitted at all for generated CSS with zero config. Or, with some configuration for postcss, it's possible to make some sourcemaps to be inlined in same generated CSS, but they contains incorrect path to source file, and can't be used in Chrome Dev Tools.

πŸŽ› Configuration (.babelrc, package.json, cli command)

I've tried with no config at all, and with all combination of next flags in package.json

  "postcss": {
    "map": {
      "inline": true,
      "sourcesContent": false,
      "from": "./src"
    },
    "plugins": {
      "autoprefixer": {}
    }
  },
  "stylus": {
    "sourcemap": {
      "comment": false,
      "inline": false,
      "basePath": "./src"
    }
  }

πŸ€” Expected Behavior

Expects that somehow user can get sourcemaps for CSS that will be fine used in Chrome Dev Tools to see what file contains what style

😯 Current Behavior

When I build a simple html file with linked Stylus file (at glance I think that for any preprocessor dialect) and have zero configuration, then no sourcemaps emitted.

With some configuration in package.json for postcss block, it's possible to make some sourcemaps to be inlined in CSS (it's postcss stuff really, not a parcel one), but their contains incorrect path to source files

πŸ’ Possible Solution

Let me think... )

πŸ”¦ Context

My project is VueJS with vue components, where for styling I use Stylus and for templates the Pug being used, with TypeScript, that majestically rises above all stuff...

But in simple configuration one html + one stylus file it's the same behavior

πŸ’» Code Sample

https://gist.github.com/ocoka/918fad4442f49714cfd69a85f67e61f1

🌍 Your Environment

Software Version(s)
Parcel 1.97
Node 8.11.3
npm/Yarn 6.2.0
Operating System Ubuntu 16.04
@DeMoorJasper
Copy link
Member

DeMoorJasper commented Jul 30, 2018

Well this just hasn't been implemented at all, I changed this to a feature request.

It's not being used that much as far as I know so it wasn't really a pressing matter for me personally when I implemented the JS sourcemap support

@DeMoorJasper DeMoorJasper changed the title No sourcemaps for generated CSS Implement sourcemaps for CSS Aug 7, 2018
@coussej
Copy link

coussej commented Aug 12, 2018

Hi @DeMoorJasper,

It's not being used that much as far as I know

For example, when building a site based on Bulma (or any other css framework fot that matter), you'd import te Bulma sass file and combine it with some custom declarations. When debugging, finding the origin of a certain property in the resulting generated css file can be very cumbersome, and sourcemaps are very useful!

@ocoka
Copy link
Author

ocoka commented Aug 12, 2018

Yep, of course it is so, and worth to mention Chrome Dev Tools feature to organize editable workspace, where you can change code right in browser and see the result immediately even without any hot reload machinery, and that's why I've switched temporary back to webpack4, with their almost zero config feature in v4, although there is also present some bugs with sourcemap in stylus-loader πŸ˜†

@DeMoorJasper
Copy link
Member

I meant it's less commonly used as js sourcemaps.

It'll eventually get implemented, my personal focus is currently not on css sourcemaps as I never use them.

If anyone however does want to contribute css sourcemaps or want to improve the current css handlers (as they are far from perfect) it would be very much appreciated.

@tnhu
Copy link

tnhu commented Aug 21, 2018

+1

This is much needed. PostCSS' inline sourcemap works in dev mode, but not ready an option for production-ready build. Without sourcemap, it'd be extremely hard to debug production issues.

@probablykasper
Copy link

Would prioritize this one a lot. If you use a preprocessor with some nesting, it's often very hard to find out where styles are coming from - Especially if you didn't write that code.

@ab18556
Copy link

ab18556 commented Dec 2, 2018

+1 this one might be a show stopper for me.

@mischnic mischnic mentioned this issue Jan 1, 2019
10 tasks
@devongovett devongovett added CSS CSS Preprocessing All the PostCSS, Less, SASS, etc issues and removed CSS labels Jan 6, 2019
@dongyuwei
Copy link

for less, add .lessrc with the following config:

{
    relativeUrls: true,
    dumpLineNumbers: 'comments'
}

This is the poor-man's source-map currently, though it's not the real sourcemap, it's very helpful to debug less/css issue.

Ref: http://lesscss.org/usage/#using-less-in-the-browser-debugging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants