mirror of
https://github.com/ichaly/cohere.git
synced 2026-07-22 07:47:20 +00:00
Switch build to Vite
This commit is contained in:
parent
5fa6f37ef4
commit
7a3581b7fc
7 changed files with 761 additions and 375 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,6 +1,6 @@
|
|||
node_modules/
|
||||
dist/
|
||||
main.js
|
||||
styles.css
|
||||
*.hot-update.*
|
||||
.DS_Store
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@ npm install
|
|||
npm run build
|
||||
```
|
||||
|
||||
The build uses Vite and writes the Obsidian plugin bundle to `main.js`.
|
||||
|
||||
## Plugin ID
|
||||
|
||||
```text
|
||||
obsync
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
import esbuild from "esbuild";
|
||||
import process from "node:process";
|
||||
import builtins from "builtin-modules";
|
||||
|
||||
const banner = `/*
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
if you want to view the source, please visit the github repository
|
||||
*/`;
|
||||
|
||||
const prod = process.argv.includes("production");
|
||||
const watch = process.argv.includes("watch");
|
||||
|
||||
const context = await esbuild.context({
|
||||
banner: {
|
||||
js: banner,
|
||||
},
|
||||
entryPoints: ["src/main.ts"],
|
||||
bundle: true,
|
||||
external: [
|
||||
"obsidian",
|
||||
"electron",
|
||||
"@codemirror/autocomplete",
|
||||
"@codemirror/collab",
|
||||
"@codemirror/commands",
|
||||
"@codemirror/language",
|
||||
"@codemirror/lint",
|
||||
"@codemirror/search",
|
||||
"@codemirror/state",
|
||||
"@codemirror/view",
|
||||
"@lezer/common",
|
||||
"@lezer/highlight",
|
||||
"@lezer/lr",
|
||||
...builtins,
|
||||
],
|
||||
format: "cjs",
|
||||
target: "es2018",
|
||||
logLevel: "info",
|
||||
sourcemap: prod ? false : "inline",
|
||||
treeShaking: true,
|
||||
outfile: "main.js",
|
||||
});
|
||||
|
||||
if (watch) {
|
||||
await context.watch();
|
||||
} else {
|
||||
await context.rebuild();
|
||||
await context.dispose();
|
||||
}
|
||||
|
||||
1019
package-lock.json
generated
1019
package-lock.json
generated
File diff suppressed because it is too large
Load diff
10
package.json
10
package.json
|
|
@ -4,8 +4,8 @@
|
|||
"description": "Obsidian plugin for OSS / S3-compatible vault sync.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"dev": "node esbuild.config.mjs watch",
|
||||
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production"
|
||||
"dev": "vite build --watch",
|
||||
"build": "tsc --noEmit --skipLibCheck && vite build"
|
||||
},
|
||||
"keywords": [
|
||||
"obsidian",
|
||||
|
|
@ -18,10 +18,8 @@
|
|||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.10.1",
|
||||
"builtin-modules": "^5.0.0",
|
||||
"esbuild": "^0.27.0",
|
||||
"obsidian": "^1.8.7",
|
||||
"typescript": "^5.9.3"
|
||||
"typescript": "^6.0.3",
|
||||
"vite": "^8.0.16"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"inlineSourceMap": true,
|
||||
"inlineSources": true,
|
||||
"module": "ESNext",
|
||||
"target": "ES2018",
|
||||
"allowJs": true,
|
||||
"noImplicitAny": true,
|
||||
"moduleResolution": "node",
|
||||
"moduleResolution": "Bundler",
|
||||
"importHelpers": true,
|
||||
"isolatedModules": true,
|
||||
"strictNullChecks": true,
|
||||
|
|
@ -20,4 +19,3 @@
|
|||
"src/**/*.ts"
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
|||
49
vite.config.ts
Normal file
49
vite.config.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import { copyFileSync, existsSync } from "node:fs";
|
||||
import { builtinModules } from "node:module";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
const obsidianExternals = [
|
||||
"obsidian",
|
||||
"electron",
|
||||
"@codemirror/autocomplete",
|
||||
"@codemirror/collab",
|
||||
"@codemirror/commands",
|
||||
"@codemirror/language",
|
||||
"@codemirror/lint",
|
||||
"@codemirror/search",
|
||||
"@codemirror/state",
|
||||
"@codemirror/view",
|
||||
"@lezer/common",
|
||||
"@lezer/highlight",
|
||||
"@lezer/lr",
|
||||
];
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
{
|
||||
name: "copy-obsidian-plugin-bundle",
|
||||
closeBundle() {
|
||||
if (existsSync("dist/main.js")) {
|
||||
copyFileSync("dist/main.js", "main.js");
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
build: {
|
||||
lib: {
|
||||
entry: "src/main.ts",
|
||||
formats: ["cjs"],
|
||||
},
|
||||
minify: false,
|
||||
outDir: "dist",
|
||||
rollupOptions: {
|
||||
external: [...obsidianExternals, ...builtinModules],
|
||||
output: {
|
||||
entryFileNames: "main.js",
|
||||
exports: "default",
|
||||
},
|
||||
},
|
||||
sourcemap: "inline",
|
||||
target: "es2018",
|
||||
},
|
||||
});
|
||||
Loading…
Reference in a new issue