Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 0ea4f7a

Browse files
committed
設定jsonがない場合の処理を追加
1 parent 63741e9 commit 0ea4f7a

File tree

2 files changed

+36
-17
lines changed

2 files changed

+36
-17
lines changed

index.js

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ module.exports = class Next2DWebpackAutoLoaderPlugin
7373
fs.writeFileSync(
7474
`${envPath}/index.html`,
7575
`<!DOCTYPE html>
76-
<html lang="en">
76+
<html>
7777
<head>
7878
<meta charset="utf-8"/>
7979
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
@@ -92,26 +92,45 @@ module.exports = class Next2DWebpackAutoLoaderPlugin
9292
"routing": {}
9393
};
9494

95-
const envJson = JSON.parse(
96-
fs.readFileSync(`${cd}/src/config/config.json`, { "encoding": "utf8" })
97-
);
98-
const stageJson = JSON.parse(
99-
fs.readFileSync(`${cd}/src/config/stage.json`, { "encoding": "utf8" })
100-
);
101-
const routingJson = JSON.parse(
102-
fs.readFileSync(`${cd}/src/config/routing.json`, { "encoding": "utf8" })
103-
);
95+
const configPath = `${cd}/src/config/config.json`;
96+
if (fs.existsSync(configPath)) {
97+
98+
const envJson = JSON.parse(
99+
fs.readFileSync(configPath, { "encoding": "utf8" })
100+
);
101+
102+
if (this._$env in envJson) {
103+
Object.assign(config, envJson[this._$env]);
104+
}
105+
106+
if (envJson.all) {
107+
Object.assign(config, envJson.all);
108+
}
109+
}
110+
111+
const stagePath = `${cd}/src/config/stage.json`;
112+
if (fs.existsSync(stagePath)) {
113+
114+
const stageJson = JSON.parse(
115+
fs.readFileSync(stagePath, { "encoding": "utf8" })
116+
);
117+
118+
Object.assign(config.stage, stageJson);
119+
}
120+
121+
const routingPath = `${cd}/src/config/routing.json`;
122+
if (fs.existsSync(routingPath)) {
123+
124+
const routingJson = JSON.parse(
125+
fs.readFileSync(routingPath, { "encoding": "utf8" })
126+
);
104127

105-
if (this._$env in envJson) {
106-
Object.assign(config, envJson[this._$env]);
128+
Object.assign(config.routing, routingJson);
107129
}
108-
Object.assign(config, envJson.all);
109-
Object.assign(config.stage, stageJson);
110-
Object.assign(config.routing, routingJson);
111130

112131
fs.writeFileSync(
113132
`${cd}/src/config/Config.js`,
114-
`const config = ${JSON.stringify(config, null, 2)};${os.EOL}export { config };`
133+
`const config = ${JSON.stringify(config, null, 4)};${os.EOL}export { config };`
115134
);
116135

117136
glob(`${cd}/src/**/*.js`, (err, files) =>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@next2d/webpack-auto-loader-plugin",
33
"description": "Next2D Framework webpack Auto Loader plugin.",
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"author": "Toshiyuki Ienaga <[email protected]>",
66
"license": "MIT",
77
"main": "index.js",

0 commit comments

Comments
 (0)