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

Sourcemaps compatibility with postcss-import #153

Closed
mdmoreau opened this issue Aug 19, 2017 · 2 comments
Closed

Sourcemaps compatibility with postcss-import #153

mdmoreau opened this issue Aug 19, 2017 · 2 comments

Comments

@mdmoreau
Copy link
Contributor

mdmoreau commented Aug 19, 2017

I've been trying to get sourcemaps to work when using postcss-import via postcss-cli, but I can't seem to figure out what's going wrong. Here's my npm script that's handling the task:

postcss src/css/main.css --use postcss-import postcss-mixins postcss-cssnext postcss-clean --output dist/css/main.min.css --map --watch

Everything works correctly except the sources that are set on the external .map file. The start of that file always reads as this:

{
  "version":3,
  "sources":[
    "<input css 1>"
  ],
  "names":[

  ],
  "mappings":"AAAA..."
}

Every time the task runs, the <input css 1> increments by one. Is there some config option that I'm missing? The closest I've gotten it to working is by using the package.json config to set the postcss map from value to match the input file, but then sources all just show main.css (with import statements) instead of the individual files.

Thanks in advance - really appreciate all the work on this tool!

@michael-ciniawsky
Copy link
Contributor

Does this also happen if you don't use @import (postcss-import) ? <input css 1> is the file placeholder in case options.from === undefined. Normally postcss input.css -o output.css the CLI uses path.resolve(input.css) to set options.from automatically and there shouldn't be any need to set it via config or to be more precise setting options.from via config shouldn't work at all. Can you paste your full config/setup please

  1. tree $PROJECT (File Tree)
  2. main.css && main.css.map
  3. package.json
  4. OS && CLI Version

@mdmoreau
Copy link
Contributor Author

Thanks for the quick response! I took another look at this with fresh eyes, and realized it was a problem with postcss-clean specifically. It's documented in an issue (leodido/postcss-clean#17) at that repo as well.

I ended up switching over to cssnano instead, and everything seems to be working properly now.

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

No branches or pull requests

2 participants