vitepress-plugin-sandpack icon indicating copy to clipboard operation
vitepress-plugin-sandpack copied to clipboard

Local dependencies

Open husayt opened this issue 1 year ago • 2 comments

Hi, thank you for this library.

How can we import local dependencies similar to what we have here: https://sandpack.codesandbox.io/docs/guides/local-dependencies

similar to the below:

import designSystemRaw from "../design-system/build-sandpack?raw";
 
<Sandpack
  files={{
    "/App.tsx": `import { Button, Tag } from "@internals/ds";
 
export default function Sample() {
  return (
    <>
      <Button type="primary">Button1</Button>
      <Button type="secondary">Button2</Button>
      <Tag>Tag</Tag>
    </>
  );
}
`,
    "/node_modules/@internals/design-system/package.json": {
      hidden: true,
      code: JSON.stringify({
        name: "@design-system",
        main: "./index.js",
      }),
    },
    "/node_modules/@internals/design-system/index.js": {
      hidden: true,
      code: designSystemRaw,
    },
  }}
  template="react-vite"
/>

husayt avatar Nov 23 '23 21:11 husayt

@husayt, I recently came across to this library while building examples for my library. But I am unable to import local dependency in the config. I could not find any solution or any workaround for this issue.

Ashish-simpleCoder avatar Jun 23 '24 16:06 Ashish-simpleCoder

I am so sorry about it, it does not support it now.

jerrywu001 avatar Jun 24 '24 01:06 jerrywu001