feat: add sandbox

This commit is contained in:
2024-02-26 10:48:17 +00:00
parent 5b68230734
commit 85e71c2983
19 changed files with 588 additions and 19 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ const get = async (req: Request, res: Response) => {
}
if (["css"].includes(ext) && settings.css?.preprocessor === "postcss") {
content = await postcss(fileData, settings.css);
content = await postcss(projectData, fileData);
}
}
+6 -6
View File
@@ -3,16 +3,16 @@ import tailwindcss from "tailwindcss";
import cssnano from "cssnano";
import { FileSchema } from "~/server/db/schema/file";
import { unpackProject } from "~/server/lib/unpack-project";
import { ProjectSettingsSchema } from "~/server/db/schema/project";
import { ProjectSchema } from "~/server/db/schema/project";
export const postcss = async (
fileData: FileSchema,
cfg?: ProjectSettingsSchema["css"]
) => {
export const postcss = async (project: ProjectSchema, fileData: FileSchema) => {
const content = fileData.content || "";
const cfg = project.settings?.css;
try {
const projectDir = await unpackProject({ ext: "ts,tsx,js,jsx,html" });
const projectDir = await unpackProject(project, {
ext: "ts,tsx,js,jsx,html",
});
const plugins: any[] = [];
if (cfg?.tailwindcss) {