mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 03:46:37 +01:00
refactor(share): use custom build plugin
This commit is contained in:
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' }
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user