vue-cli-plugin-electron-haunv 1.0.9 → 1.0.10

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.
Files changed (2) hide show
  1. package/generator/index.js +34 -16
  2. package/package.json +1 -1
@@ -53,10 +53,9 @@ module.exports = (api) => {
53
53
 
54
54
  api.onCreateComplete(() => {
55
55
  const fs = require("fs")
56
- const path = require("path")
57
-
58
56
  const configPath = api.resolve("vue.config.js")
59
57
 
58
+ // 🟢 chưa có file → tạo mới
60
59
  if (!fs.existsSync(configPath)) {
61
60
  fs.writeFileSync(
62
61
  configPath,
@@ -65,20 +64,39 @@ module.exports = (api) => {
65
64
  }
66
65
  `
67
66
  )
68
- console.log("🆕 Created vue.config.js")
69
- } else {
70
- let content = fs.readFileSync(configPath, "utf-8")
71
-
72
- if (!content.includes("publicPath")) {
73
- content = content.replace(
74
- /module\.exports\s*=\s*{/,
75
- `module.exports = {\n publicPath: "./",`
76
- )
77
-
78
- fs.writeFileSync(configPath, content)
79
- console.log("✨ Added publicPath")
80
- }
67
+ console.log("🆕 Created vue.config.js with publicPath")
68
+ return
81
69
  }
82
- })
83
70
 
71
+ let content = fs.readFileSync(configPath, "utf-8")
72
+
73
+ // 🟢 đã có publicPath → bỏ qua
74
+ if (content.includes("publicPath")) {
75
+ console.log("ℹ️ publicPath already exists")
76
+ return
77
+ }
78
+
79
+ // 🟢 inject vào module.exports
80
+ if (content.includes("module.exports")) {
81
+ content = content.replace(
82
+ /module\.exports\s*=\s*{/,
83
+ `module.exports = {\n publicPath: "./",`
84
+ )
85
+ }
86
+ // 🟡 fallback nếu là export default
87
+ else if (content.includes("export default")) {
88
+ content = content.replace(
89
+ /export\s+default\s*{/,
90
+ `export default {\n publicPath: "./",`
91
+ )
92
+ }
93
+ // 🔴 fallback cuối: append luôn
94
+ else {
95
+ content += `\n\nmodule.exports = {\n publicPath: "./"\n}\n`
96
+ }
97
+
98
+ fs.writeFileSync(configPath, content)
99
+
100
+ console.log("✨ Injected publicPath into vue.config.js")
101
+ })
84
102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-cli-plugin-electron-haunv",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "keywords": [