MDsveX icon indicating copy to clipboard operation
MDsveX copied to clipboard

Documentation must be updated.

Open Huansock opened this issue 2 years ago • 2 comments

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
);
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

Huansock avatar May 26 '22 21:05 Huansock

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.

pngwn avatar May 27 '22 10:05 pngwn

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
);

Huansock avatar May 27 '22 11:05 Huansock