Skip to content

Commit

Permalink
Merge pull request #9 from Next2D/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ienaga authored Nov 4, 2023
2 parents bb8a7e4 + 3b8ef45 commit 99ef857
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ src
.eslintrc.json
.gitattributes
.gitignore
tsconfig.eslint.json
tsconfig.json
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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<ienaga@next2d.app>",
"license": "MIT",
Expand Down
35 changes: 34 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 99ef857

Please sign in to comment.