MDsveX
MDsveX copied to clipboard
Documentation must be updated.
In Document it is written.
If you want to use mdsvex without a bundler because you are your own person, then you can use svelte.preprocess directly:
const svelte = require('svelte/compiler');
const { mdsvex } = require('mdsvex');
// This will give you a valid svelte component
const preprocessed = await svelte.preprocess(
source,
mdsvex(mdsvex_opts)
);
// Now you can compile it if you wish
const compiled = svelte.compile(
preprocessed,
compiler_options
);
- but sveltekit configuration inform us that it schould written by
import { mdsvex } from 'mdsvex'
import mdsvexConfig from './mdsvex.config.js'
import preprocess from 'svelte-preprocess'
import adapter from '@sveltejs/adapter-static'
/** @type {import('@sveltejs/kit').Config} */
const config = {
extensions: ['.svelte', ...mdsvexConfig.extensions],
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: [
mdsvex(mdsvexConfig),
[
preprocess({
postcss: true
})
]
],
like that.
for me it is more useful use "svelte add" cli code rather than following the Doucumentation. so i prefer for better documentation and examples. thank you for reading
These aren't the same thing, SvelteKit uses a bundler under the hood so this the docs there are just applying mdsvex
as it is described elsewhere in the mdsvex docs (i.e. as a preprocessor to svelte, via a bundler). We could potentially update the code to use esm rather than cjs but I'm unsure whether or not that is the best approach just yet.
Thank you for your answer pngwn, than should i replace my all line in svelte.config.js file to this? thank you for your amazing mdsvex again.
const svelte = require('svelte/compiler');
const { mdsvex } = require('mdsvex');
// This will give you a valid svelte component
const preprocessed = await svelte.preprocess(
source,
mdsvex(mdsvex_opts)
);
// Now you can compile it if you wish
const compiled = svelte.compile(
preprocessed,
compiler_options
);