Skip to content

Commit

Permalink
chore: improve development cycle
Browse files Browse the repository at this point in the history
When running npm run dev, we now optionally output to a given Obsidian
vault controlled by the VITE_OBSIDIAN_VAULT environment variable. This
can be set by .env.local in the plugin/ dir.
  • Loading branch information
jamiebrynes7 committed Feb 25, 2024
1 parent 5d7e12c commit 0d043d2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
# Plugin things
plugin/node_modules/
plugin/dist/

# Nix-related things
.direnv/
.devenv/
3 changes: 3 additions & 0 deletions plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
.env.local
2 changes: 1 addition & 1 deletion plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A Todoist plugin for Obsidian",
"scripts": {
"check": "svelte-check",
"dev": "npm run check && vite build",
"dev": "npm run check && VITE_ENV=dev vite build",
"build": "vite build",
"test": "vitest",
"format": "prettier --write src/**/*",
Expand Down
20 changes: 18 additions & 2 deletions plugin/vite.config.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import { configDefaults, defineConfig } from 'vitest/config'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import { viteStaticCopy } from 'vite-plugin-static-copy'
import { resolve } from 'path'
import path, { resolve } from 'path'
import { loadEnv } from 'vite'

function getOutDir(): string | undefined {
const env = loadEnv("prod", process.cwd());
if (env?.VITE_ENV !== "dev") {
return undefined;
}

const vaultDir = env?.VITE_OBSIDIAN_VAULT;
if (vaultDir === undefined) {
return vaultDir;
}

return path.join(vaultDir, ".obsidian", "plugins", "todoist-sync-plugin");
}

export default defineConfig({
plugins: [
Expand Down Expand Up @@ -31,7 +46,8 @@ export default defineConfig({
},
rollupOptions: {
external: ["obsidian"]
}
},
outDir: getOutDir(),
},
test: {
watch: false,
Expand Down

0 comments on commit 0d043d2

Please sign in to comment.