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

fix: paths in postcss sourcemap sources array (Sourcemap ... points to missing source files) #500

Merged
merged 1 commit into from Apr 11, 2022

Conversation

bfanger
Copy link
Contributor

@bfanger bfanger commented Apr 8, 2022

When using Vite's new devSourcemap you'll be getting warnings like:

Sourcemap for ".../src/routes/__layout.svelte" points to missing source files

Example SvelteKit project: https://github.com/bfanger/svelte-project-template

// svelte.config.js
/** @type {import('@sveltejs/kit').Config} */
export default {
  preprocess: preprocess({ sourceMap: true }),
  kit: {
    vite: { css: { devSourcemap: true } },
  },
};

When no to: is passed to postcss(), PostCSS will use NodeJS current working directory as fallback, which generates invalid paths.

This PR adds the to parameter, which allows PostCSS to generate the correct relative paths into the sourcemap sources array.

@floehopper
Copy link

I've started seeing these warnings having just upgraded from v1.0.0-next.298 -> next.310, but I don't have devSourcemap enabled. Will this also be fixed by these changes?

@bfanger
Copy link
Contributor Author

bfanger commented Apr 9, 2022

@floehopper Dig into your local node_modules/svelte-preprocess
Edit both node_modules/svelte-preprocess/dist/transformers/globalStyle.js & postcss.js

and replace:

from: filename,

with

from: filename, 
to: filename,

And see if that fixes it, if not then there is something else also generating invalid paths

@floehopper
Copy link

@bfanger Yes, that fixes them - thanks! 👍

@dummdidumm dummdidumm merged commit 2027375 into sveltejs:main Apr 11, 2022
@Gin-Quin
Copy link
Contributor

Gin-Quin commented May 6, 2022

I'm having this issue for Stylus files. I fixed it by applying path.resolve to all sourcemap sources in transformers/stylus.ts. I created a PR for that.

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

Successfully merging this pull request may close these issues.

None yet

5 participants