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

CSS sourcemaps are missing #841

Open
Rich-Harris opened this issue Apr 2, 2021 · 6 comments
Open

CSS sourcemaps are missing #841

Rich-Harris opened this issue Apr 2, 2021 · 6 comments
Labels
bug Something isn't working p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. vite
Milestone

Comments

@Rich-Harris
Copy link
Member

This is really just a placeholder issue to point at vitejs/vite#2830

@Rich-Harris Rich-Harris added the bug Something isn't working label Apr 2, 2021
@benmccann
Copy link
Member

We're adding an option in Svelte (sveltejs/svelte#6835) that we will use to disable CSS sourcemaps during SSR by default in vite-plugin-svelte because they're causing issues when using environment variables in Svelte templates (#720)

@Rich-Harris Rich-Harris added this to the 1.0 milestone Mar 5, 2022
@benmccann benmccann added p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. vite labels Mar 17, 2022
@benmccann
Copy link
Member

There's a PR for this: vitejs/vite#7173

@benmccann benmccann added help wanted PRs welcomed. The implementation details are unlikely to cause debate and removed help wanted labels Apr 4, 2022
@alexaisok
Copy link

alexaisok commented May 8, 2022

Just curious what the status of this is - I'm more of a backend developer and don't know much about vite unfortunately. It looks like their PR for enabling sourcemap generation was merged and sveltekit uses a version of vite that has the change. However npm run dev or npm run build in my project don't generate sourcemaps for my CSS/SCSS. Is this expected still?

@benmccann
Copy link
Member

You must enable the experimental option: https://vitejs.dev/config/#css-devsourcemap

@alexaisok
Copy link

alexaisok commented May 8, 2022

You must enable the experimental option: https://vitejs.dev/config/#css-devsourcemap

Edit
Disregard everything below, the sourceMappingURL's actually are there when I examine page source. I was searching the output files but I guess it makes sense that they wouldn't be there since a lot of this is composed on the clientside. Also I think my browser was doing some weird caching because I had to delete the .svelte-kit folder and restart dev for it to show the maps after enabling css.devSourcemap.

The only quirk is that the CSS selectors contain random strings (for making the selector unique to that component I assume) while the map contains the original selector. Its not a huge issue, but is there a way of showing the original selector instead? Maybe this is a just a browser thing.
Screenshot_20220508_092715


Edit - disregard this
Thanks for the quick reply. I tried this without success for either dev or build. sourceMappingURL isn't appended to css and no .map files appear in the output.

Here's my svelte.config.js ('m just using the base sveltekit demo project, with "@sveltejs/kit": "next" and "svelte": "^3.46.0.

import adapter from '@sveltejs/adapter-auto';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	compilerOptions: {
		enableSourcemap: true
	},
	kit: {
		adapter: adapter(),

		// Override http methods in the Todo forms
		methodOverride: {
			allowed: ['PATCH', 'DELETE']
		},
		vite: {
			css: {
				devSourcemap: true
			}
		}
	}
};

export default config;

@benmccann benmccann removed the help wanted PRs welcomed. The implementation details are unlikely to cause debate label Jun 3, 2022
@Rich-Harris Rich-Harris modified the milestones: 1.0, whenever Jul 20, 2022
@jz9423

This comment was marked as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. vite
Projects
None yet
Development

No branches or pull requests

4 participants