From c9b4e92816db69e812c6cfe1dc07aee7d6f54719 Mon Sep 17 00:00:00 2001 From: ienaga Date: Sat, 4 Nov 2023 20:56:12 +0900 Subject: [PATCH 1/2] update .npmignore --- .npmignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.npmignore b/.npmignore index 54b6f45..e642ab8 100644 --- a/.npmignore +++ b/.npmignore @@ -5,4 +5,5 @@ src .eslintrc.json .gitattributes .gitignore +tsconfig.eslint.json tsconfig.json \ No newline at end of file From 3b8ef457aaac0b76c69057da503e6c89df7b1939 Mon Sep 17 00:00:00 2001 From: ienaga Date: Sat, 4 Nov 2023 21:41:20 +0900 Subject: [PATCH 2/2] =?UTF-8?q?config=E3=81=AE=E5=A4=89=E6=95=B0=E3=82=92?= =?UTF-8?q?=E6=96=87=E5=AD=97=E5=88=97=E3=81=AB=E5=A4=89=E6=8F=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/index.ts | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9d8d330..c9571b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@next2d/vite-auto-loader-plugin", - "version": "0.0.6", + "version": "0.0.7", "description": "Next2D Framework vite TypeScript Auto Loader plugin.", "author": "Toshiyuki Ienaga", "license": "MIT", diff --git a/src/index.ts b/src/index.ts index 09e4d5d..3b23866 100644 --- a/src/index.ts +++ b/src/index.ts @@ -62,7 +62,40 @@ const buildConfig = (object: ObjectImpl): void => ); } - const configString: string = JSON.stringify(config, null, 4); + const regexp: RegExp = new RegExp(/{{(.*?)}}/, "g"); + + let configString: string = JSON.stringify(config, null, 4); + const values: RegExpMatchArray | null = configString.match(regexp); + if (values) { + for (let idx: number = 0; idx < values.length; ++idx) { + + const value: string = values[idx]; + + const names: string[] = value + .replace(/\{|\{|\}|\}/g, "") + .replace(/\s+/g, "") + .split("."); + + if (!names.length) { + continue; + } + + let configValue: any = config; + for (let idx: number = 0; idx < names.length; ++idx) { + const name: string = names[idx]; + if (name in configValue) { + configValue = configValue[name]; + } + } + + if (config === configValue) { + continue; + } + + configString = configString.replace(value, configValue); + } + } + if (cacheConfig !== configString) { // cache update