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 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