Last active
June 29, 2021 13:41
-
-
Save kevboh/e2e15bf06bfb904690523e48db2c35a9 to your computer and use it in GitHub Desktop.
rollup config for obsidian dev w/ svelte
This file contains hidden or 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
import svelte from "rollup-plugin-svelte"; | |
import typescript from "@rollup/plugin-typescript"; | |
import { nodeResolve } from "@rollup/plugin-node-resolve"; | |
import commonjs from "@rollup/plugin-commonjs"; | |
import sveltePreprocess from "svelte-preprocess"; | |
import copy from "rollup-plugin-copy"; | |
import { env } from "process"; | |
const isProd = env.BUILD === "production"; | |
const isWatching = env.ROLLUP_WATCH === "true"; | |
const pluginDir = env.PLUGINS_DIR; | |
const banner = `/* | |
THIS IS A GENERATED/BUNDLED FILE BY ROLLUP | |
if you want to view the source visit the plugins github repository | |
*/ | |
`; | |
export default { | |
input: "src/main.ts", | |
output: { | |
dir: ".", | |
sourcemap: !isProd, | |
format: "cjs", | |
exports: "default", | |
banner, | |
}, | |
external: ["obsidian"], | |
plugins: [ | |
svelte({ | |
emitCss: false, | |
preprocess: sveltePreprocess(), | |
}), | |
typescript({ sourceMap: !isProd, inlineSources: !isProd }), | |
nodeResolve({ browser: true, dedupe: ["svelte"] }), | |
commonjs({ | |
include: "node_modules/**", | |
}), | |
isWatching && | |
pluginDir && | |
copy({ | |
targets: [ | |
{ | |
src: ["main.js", "manifest.json", "styles.css"], | |
dest: pluginDir + "/[YOUR PLUGIN DIR]/", | |
}, | |
], | |
hook: "writeBundle", | |
verbose: true, | |
overwrite: true, | |
}), | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some notes:
[YOUR PLUGIN DIR]
to match the directory of the plugin you're working in.env.PLUGINS_DIR
is an env var you'll need to set. It's the path to your.obsidian/plugins
directory in whatever vault you're using for testing.