Skip to content

Commit

Permalink
Minify main.js to improve plugin load time
Browse files Browse the repository at this point in the history
Fixes argenos#161

Add minification to the build process for `main.js`.

* **rollup.config.js**
  - Import `esbuild` from `rollup-plugin-esbuild` and `terser` from `rollup-plugin-terser`.
  - Add `esbuild` and `terser` to the `plugins` array for minification.

* **package.json**
  - Add `rollup-plugin-esbuild` as a devDependency.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/argenos/nldates-obsidian/issues/161?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
Kageetai committed Nov 25, 2024
1 parent 58849aa commit f0c5ad9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"obsidian": "latest",
"prettier": "2.4.1",
"tslib": "2.4.0",
"typescript": "4.7.4"
"typescript": "4.7.4",
"rollup-plugin-esbuild": "^4.7.0"
},
"dependencies": {
"chrono-node": "github:liamcain/chrono",
Expand Down
32 changes: 17 additions & 15 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import typescript from "@rollup/plugin-typescript";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";

export default {
input: "src/main.ts",
output: {
dir: ".",
sourcemap: "inline",
format: "cjs",
exports: "default",
},
external: ["obsidian"],
plugins: [typescript(), nodeResolve({ browser: true }), commonjs()],
};
import typescript from "@rollup/plugin-typescript";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import esbuild from "rollup-plugin-esbuild";
import { terser } from "rollup-plugin-terser";

export default {
input: "src/main.ts",
output: {
dir: ".",
sourcemap: "inline",
format: "cjs",
exports: "default",
},
external: ["obsidian"],
plugins: [typescript(), nodeResolve({ browser: true }), commonjs(), esbuild({ minify: true }), terser()],
};

0 comments on commit f0c5ad9

Please sign in to comment.