3.9.1 • Published 1 year ago

svokit v3.9.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Svokit.io

This module allows socket.io to bind to a sveltekit (vite) server Start by initializing a sveltekit server: npm create @svelte-add/kit@latest Next, install this library: npm i svokit@latest

Config

To initialize svokit, you'll need to create a svokit config, and apply the plugin to the vite config:

svokit.config.mjs

import { defineConfig } from "svokit"
// code here must be written in mjs compatible format, $lib does not apply here.
export default defineConfig({
    out: 'build', // Same as out in svelte config
    mount(io, server/*optional*/) {
		// socket.io code here
        console.log(io)
    }
})

vite.config.cjs

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

/** @type {import('vite').UserConfig} */
const config = {
	// ...
	plugins: [sveltekit(), svokit(), /*...*/]
}

export default config;

Your svelte.config.js should look similar to this

import adapter from '@sveltejs/adapter-node'; //? Only works with adapter node
import preprocess from 'svelte-preprocess';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	// ...
	kit: {
		// ...
		adapter: adapter({
			out: "build" //? should be the same as out in svokit config 
		})
	}
};

export default config;

Make sure @sveltejs/adapter-node is installed in lieu of @sveltejs/adapter-auto that comes with svelte-add

To run the built app, instead of running node buildfolder, run npx svokit, or just svokit in package scripts.

3.9.1

1 year ago

3.9.0

1 year ago

3.8.0

1 year ago

3.7.5

2 years ago

3.7.4

2 years ago

3.7.3

2 years ago

3.6.3

2 years ago

3.7.9

2 years ago

3.7.8

2 years ago

3.7.7

2 years ago

3.7.6

2 years ago

3.3.1

2 years ago

3.2.1

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.5.3

2 years ago

3.5.2

2 years ago

3.4.2

2 years ago

3.4.1

2 years ago

2.0.0

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

0.0.1

2 years ago