Skip to content

Commit

Permalink
feat: support "environment"
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed May 28, 2022
1 parent e053e96 commit 868f542
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion public/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Open editor at first.
<!-- sandpack:{
"files": {
"/src/index.js": {
"prependCode": "import '/src/index.css'; // Hack to load index.css\n",
"prependCode": "import './index.css'; // Hack to load index.css. require parcel env \n",
"path": "example2/src/index.js"
},
"/src/App.js": {
Expand All @@ -52,6 +52,7 @@ Open editor at first.
}
},
"entry": "/index.html",
"environment": "parcel",
"options": {
"showLineNumbers": true,
"showInlineErrors": true,
Expand Down
1 change: 1 addition & 0 deletions public/SECOND.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Open editor at first.
}
},
"entry": "/index.html",
"environment": "parcel",
"options": {
"showLineNumbers": true,
"showInlineErrors": true,
Expand Down
5 changes: 3 additions & 2 deletions src/sandpack.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Sandpack, SandpackPredefinedTemplate, SandpackSetup } from "@codesandbox/sandpack-react";
import { SandboxEnvironment, Sandpack, SandpackPredefinedTemplate, SandpackSetup } from "@codesandbox/sandpack-react";
import React from "react";
import { createRoot } from "react-dom/client";
import { parseCommentAsSandboxOptions } from "./parse-comment-as-sandbox-options";
Expand All @@ -25,6 +25,7 @@ export type SandboxOptions = {
dependencies?: SandboxInfo["dependencies"];
devDependencies?: SandboxInfo["devDependencies"];
entry?: string;
environment?: SandboxEnvironment;
/**
* What template we use, if not defined we infer the template from the dependencies or files.
*/
Expand Down Expand Up @@ -110,7 +111,7 @@ export const attachToElement = (element: HTMLElement | ChildNode, options: Sandb
entry: options.entry,
dependencies: options.dependencies,
devDependencies: options.devDependencies,
environment: "parcel"
environment: options.environment ?? "static"
};
const entry = options.entry;
const sandpackOptions = options.options;
Expand Down

0 comments on commit 868f542

Please sign in to comment.