-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add new build for styleless (#798)
Co-authored-by: Danilo Woznica <[email protected]>
- Loading branch information
Showing
14 changed files
with
879 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,3 +106,6 @@ dist | |
|
||
# Mac | ||
.DS_Store | ||
|
||
# Vscode | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Sandpack } from "@codesandbox/sandpack-react"; | ||
|
||
const App = () => { | ||
return ( | ||
<div> | ||
<Sandpack /> | ||
<Sandpack theme="dark" /> | ||
<Sandpack template="nextjs" /> | ||
<Sandpack options={{ readOnly: true }} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/index.jsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { StrictMode } from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
|
||
import App from "./App"; | ||
|
||
const root = createRoot(document.getElementById("root")); | ||
root.render( | ||
<StrictMode> | ||
<App /> | ||
</StrictMode> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-react": "3.1.0", | ||
"vite": "4.0.0", | ||
"esbuild-wasm": "0.15.12" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineConfig } from "vite"; | ||
import react from "@vitejs/plugin-react"; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react()], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const path = require("path"); | ||
|
||
const walk = require("acorn-walk"); | ||
const { generate } = require("astring"); | ||
|
||
module.exports = function () { | ||
return { | ||
name: "remove-css", | ||
transform(code, id) { | ||
const ast = this.parse(code); | ||
|
||
const idArr = id.split("/"); | ||
idArr.pop(); | ||
|
||
const sourceDirPath = idArr.join("/"); | ||
|
||
let isCssImported = false; | ||
|
||
walk.simple(ast, { | ||
ImportDeclaration: (_node) => { | ||
if ( | ||
path.resolve(sourceDirPath, _node.source.value) === | ||
path.join(__dirname, "../src/styles") | ||
) { | ||
const specify = _node.specifiers?.find( | ||
(specify) => specify.imported.name === "css" | ||
); | ||
|
||
if (specify) { | ||
isCssImported = true; | ||
specify.imported.name = "fakeCss"; | ||
specify.local.name = "fakeCss"; | ||
} | ||
} | ||
}, | ||
CallExpression: (_node) => { | ||
if (_node.callee.name === "css" && isCssImported) { | ||
_node.type = "Identifier"; | ||
_node.name = "fakeCss"; | ||
delete _node.arguments; | ||
} | ||
}, | ||
}); | ||
|
||
return { | ||
code: generate(ast), | ||
}; | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
d9e475d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
sandpack-docs – ./website/docs
sandpack-docs-codesandbox1.vercel.app
sandpack-docs-git-main-codesandbox1.vercel.app
sandpack.vercel.app