Skip to content

Commit 868f542

Browse files
committed
feat: support "environment"
1 parent e053e96 commit 868f542

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

public/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Open editor at first.
3636
<!-- sandpack:{
3737
"files": {
3838
"/src/index.js": {
39-
"prependCode": "import '/src/index.css'; // Hack to load index.css\n",
39+
"prependCode": "import './index.css'; // Hack to load index.css. require parcel env \n",
4040
"path": "example2/src/index.js"
4141
},
4242
"/src/App.js": {
@@ -52,6 +52,7 @@ Open editor at first.
5252
}
5353
},
5454
"entry": "/index.html",
55+
"environment": "parcel",
5556
"options": {
5657
"showLineNumbers": true,
5758
"showInlineErrors": true,

public/SECOND.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Open editor at first.
5353
}
5454
},
5555
"entry": "/index.html",
56+
"environment": "parcel",
5657
"options": {
5758
"showLineNumbers": true,
5859
"showInlineErrors": true,

src/sandpack.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Sandpack, SandpackPredefinedTemplate, SandpackSetup } from "@codesandbox/sandpack-react";
1+
import { SandboxEnvironment, Sandpack, SandpackPredefinedTemplate, SandpackSetup } from "@codesandbox/sandpack-react";
22
import React from "react";
33
import { createRoot } from "react-dom/client";
44
import { parseCommentAsSandboxOptions } from "./parse-comment-as-sandbox-options";
@@ -25,6 +25,7 @@ export type SandboxOptions = {
2525
dependencies?: SandboxInfo["dependencies"];
2626
devDependencies?: SandboxInfo["devDependencies"];
2727
entry?: string;
28+
environment?: SandboxEnvironment;
2829
/**
2930
* What template we use, if not defined we infer the template from the dependencies or files.
3031
*/
@@ -110,7 +111,7 @@ export const attachToElement = (element: HTMLElement | ChildNode, options: Sandb
110111
entry: options.entry,
111112
dependencies: options.dependencies,
112113
devDependencies: options.devDependencies,
113-
environment: "parcel"
114+
environment: options.environment ?? "static"
114115
};
115116
const entry = options.entry;
116117
const sandpackOptions = options.options;

0 commit comments

Comments
 (0)