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

Convert build to Vite plugin and expose as @sveltejs/kit/experimental/vite #5094

Merged
merged 68 commits into from
Jun 24, 2022

Conversation

benmccann
Copy link
Member

@benmccann benmccann commented May 27, 2022

Ref #4329

I didn't document it yet as it's still experimental. I'd also like to get feedback about using it with Vitest, Storybook, etc.

You should be able to use it with a vite.config.js that looks like:

import { sveltekit } from '@sveltejs/kit/experimental/vite';

export default {
  plugins: [ sveltekit() ]
};

For example, you can run the kit.svelte.dev site with the following vite.config.js after removing the vite config from svelte.config.js:

import * as path from 'path';
import { sveltekit } from '@sveltejs/kit/experimental/vite'
import { imagetools } from 'vite-imagetools';

export default {
	plugins: [ imagetools(), sveltekit() ],

	resolve: {
		alias: {
			$img: path.resolve('src/images')
		}
	},

	server: {
		fs: {
			strict: false
		}
	}
};

Some of this code may be able to be cleaned up when we drop support for vite config in svelte.config.js. We may also be able to cleanup some vite-plugin-svelte code if this proposal moves forward: vitejs/vite#8509

Update: this now supports preview as well (#5170) as dev and build

@changeset-bot
Copy link

changeset-bot bot commented May 27, 2022

🦋 Changeset detected

Latest commit: 4638cb2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@benmccann
Copy link
Member Author

@nickbreaton @JessicaSachs FYI. I hope this might help you. I'd love some feedback if you're able to try it out at some point

@JessicaSachs
Copy link

!!! NICE. I'm looking forward to trying this out post-conferences... So.... mid-June? Unless @BlueWinds wants to give it a go first.

@bitdom8
Copy link

bitdom8 commented Jun 27, 2022

Can you share a svelte.config.file? @benmccann. My code is broken #5283

import adapter from '@sveltejs/adapter-node';
import preprocess from 'svelte-preprocess';
import path from 'path'


export default {
	kit: {
		  adapter: adapter({ }),
		  alias: {
			$i18n: path.resolve('./src/i18n'),
			// $lib: path.resolve('./src/lib'),
			$src: path.resolve('./src'),
			$locales: path.resolve('./locales'),
		},
	},
		preprocess : preprocess({
		preserve: ['ld+json'],
	  }),
  };

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.

4 participants