vue-cli-plugin-electron-haunv 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generator/index.js +26 -38
- package/package.json +1 -1
package/generator/index.js
CHANGED
|
@@ -55,48 +55,36 @@ module.exports = (api) => {
|
|
|
55
55
|
const fs = require("fs")
|
|
56
56
|
const configPath = api.resolve("vue.config.js")
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
publicPath: "./"
|
|
64
|
-
}
|
|
65
|
-
`
|
|
66
|
-
)
|
|
67
|
-
console.log("🆕 Created vue.config.js with publicPath")
|
|
68
|
-
return
|
|
69
|
-
}
|
|
58
|
+
setTimeout(() => {
|
|
59
|
+
if (!fs.existsSync(configPath)) {
|
|
60
|
+
console.log("⚠️ vue.config.js not found")
|
|
61
|
+
return
|
|
62
|
+
}
|
|
70
63
|
|
|
71
|
-
|
|
64
|
+
let content = fs.readFileSync(configPath, "utf-8")
|
|
72
65
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
66
|
+
if (content.includes("publicPath")) {
|
|
67
|
+
console.log("ℹ️ already has publicPath")
|
|
68
|
+
return
|
|
69
|
+
}
|
|
78
70
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
content =
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
// 🔴 fallback cuối: append luôn
|
|
94
|
-
else {
|
|
95
|
-
content += `\n\nmodule.exports = {\n publicPath: "./"\n}\n`
|
|
96
|
-
}
|
|
71
|
+
// 👉 tìm dấu } cuối cùng
|
|
72
|
+
const lastIndex = content.lastIndexOf("}")
|
|
73
|
+
|
|
74
|
+
if (lastIndex === -1) {
|
|
75
|
+
console.log("❌ cannot find end of config")
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 👉 chèn trước dấu }
|
|
80
|
+
content =
|
|
81
|
+
content.slice(0, lastIndex) +
|
|
82
|
+
`,\n publicPath: "./"\n` +
|
|
83
|
+
content.slice(lastIndex)
|
|
97
84
|
|
|
98
|
-
|
|
85
|
+
fs.writeFileSync(configPath, content, "utf-8")
|
|
99
86
|
|
|
100
|
-
|
|
87
|
+
console.log("✅ Inject success REAL")
|
|
88
|
+
}, 500)
|
|
101
89
|
})
|
|
102
90
|
}
|