diff --git a/packages/share-theme/package.json b/packages/share-theme/package.json index 8950f47a2..612092765 100644 --- a/packages/share-theme/package.json +++ b/packages/share-theme/package.json @@ -18,7 +18,6 @@ "license": "ISC", "devDependencies": { "@digitak/esrun": "^3.2.24", - "@digitalmaas/esbuild-plugin-ejs": "1.0.0", "@types/swagger-ui": "^3.52.0", "@typescript-eslint/eslint-plugin": "^6.7.2", "@typescript-eslint/parser": "^6.7.2", diff --git a/packages/share-theme/scripts/build.ts b/packages/share-theme/scripts/build.ts index ef36d1804..39d24c962 100644 --- a/packages/share-theme/scripts/build.ts +++ b/packages/share-theme/scripts/build.ts @@ -1,6 +1,6 @@ import fs from "node:fs"; 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 dotenv from "dotenv"; diff --git a/packages/share-theme/scripts/esbuild-ejs-plugin.ts b/packages/share-theme/scripts/esbuild-ejs-plugin.ts new file mode 100644 index 000000000..1b74bc283 --- /dev/null +++ b/packages/share-theme/scripts/esbuild-ejs-plugin.ts @@ -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' } + }) + } + } +}