mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
refactor(share): use custom build plugin
This commit is contained in:
parent
d6bb790e26
commit
7e443e7b8d
@ -18,7 +18,6 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@digitak/esrun": "^3.2.24",
|
"@digitak/esrun": "^3.2.24",
|
||||||
"@digitalmaas/esbuild-plugin-ejs": "1.0.0",
|
|
||||||
"@types/swagger-ui": "^3.52.0",
|
"@types/swagger-ui": "^3.52.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.7.2",
|
"@typescript-eslint/eslint-plugin": "^6.7.2",
|
||||||
"@typescript-eslint/parser": "^6.7.2",
|
"@typescript-eslint/parser": "^6.7.2",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import ejsPlugin from "@digitalmaas/esbuild-plugin-ejs";
|
import ejsPlugin from "./esbuild-ejs-plugin.js";
|
||||||
// import {fileURLToPath} from "node:url";
|
// import {fileURLToPath} from "node:url";
|
||||||
|
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
|
21
packages/share-theme/scripts/esbuild-ejs-plugin.ts
Normal file
21
packages/share-theme/scripts/esbuild-ejs-plugin.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { readFile } from 'fs/promises';
|
||||||
|
import { compile } from 'ejs';
|
||||||
|
|
||||||
|
export default function esbuildPluginEjs(options = {}) {
|
||||||
|
return {
|
||||||
|
name: 'ejs',
|
||||||
|
setup(build) {
|
||||||
|
build.onLoad({ filter: /\.ejs$/ }, async args => {
|
||||||
|
const template = await readFile(args.path, 'utf8')
|
||||||
|
const ejsOptions = {
|
||||||
|
...options,
|
||||||
|
client: true,
|
||||||
|
strict: true,
|
||||||
|
compileDebug: false }
|
||||||
|
const generator = compile(template, ejsOptions)
|
||||||
|
const contents = `module.exports = ${generator.toString()};`
|
||||||
|
return { contents, loader: 'js' }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user