mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-10-30 00:27:43 +09:00
## Description 1. What is this PR about (link the issue and add a short description) ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { defineConfig } from "vite";
|
|
import pkg from "./package.json";
|
|
|
|
const isExternal = (id: string, importer: string | undefined) => {
|
|
if (id.startsWith("@webstudio-is/")) {
|
|
return false;
|
|
}
|
|
if (id.startsWith("node:")) {
|
|
return true;
|
|
}
|
|
if (id.startsWith("@")) {
|
|
const packageName = id.split("/").slice(0, 2).join("/");
|
|
if (packageName in pkg.dependencies === false) {
|
|
throw Error(
|
|
`${packageName} imported from ${importer} is not found in direct dependencies`
|
|
);
|
|
}
|
|
return true;
|
|
}
|
|
if (id.includes(".") === false) {
|
|
const [packageName] = id.split("/");
|
|
if (packageName in pkg.dependencies === false) {
|
|
throw Error(
|
|
`${packageName} imported from ${importer} is not found in direct dependencies`
|
|
);
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
export default defineConfig({
|
|
// resolve only webstudio condition in tests
|
|
build: {
|
|
minify: false,
|
|
lib: {
|
|
entry: ["src/cli.ts"],
|
|
formats: ["es"],
|
|
},
|
|
rollupOptions: {
|
|
external: isExternal,
|
|
output: {
|
|
dir: "lib",
|
|
},
|
|
},
|
|
},
|
|
});
|