@quicktvui/web-cli 1.0.0-beta.16 → 1.0.0-beta.18
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/bin/qt-web-cli.js +34 -24
- package/lib/webpack.config.js +0 -10
- package/package.json +1 -1
package/bin/qt-web-cli.js
CHANGED
|
@@ -47,8 +47,7 @@ Examples:
|
|
|
47
47
|
qt-web-cli --config ./my.webpack.js
|
|
48
48
|
|
|
49
49
|
特点:
|
|
50
|
-
-
|
|
51
|
-
- 若无 webMain,自动使用 src/web 或 @quicktvui/web-renderer 包
|
|
50
|
+
- 自动检测项目入口 (main-native.ts/js, main.ts/js)
|
|
52
51
|
- 零配置启动 web 开发服务器
|
|
53
52
|
`)
|
|
54
53
|
process.exit(0)
|
|
@@ -76,23 +75,32 @@ async function main() {
|
|
|
76
75
|
let mainEntry
|
|
77
76
|
let entryType
|
|
78
77
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
78
|
+
// 入口候选列表
|
|
79
|
+
const entryCandidates = [
|
|
80
|
+
{ name: 'src/main-native.ts', path: './src/main-native.ts', type: 'package' },
|
|
81
|
+
{ name: 'src/main-native.js', path: './src/main-native.js', type: 'package' },
|
|
82
|
+
{ name: 'src/main.ts', path: './src/main.ts', type: 'package' },
|
|
83
|
+
{ name: 'src/main.js', path: './src/main.js', type: 'package' },
|
|
84
|
+
{ name: 'main (package.json)', path: pkg.main, type: 'package' },
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
for (const candidate of entryCandidates) {
|
|
88
|
+
if (!candidate.path) continue
|
|
89
|
+
const entryFullPath = path.resolve(projectRoot, candidate.path)
|
|
90
|
+
if (fs.existsSync(entryFullPath)) {
|
|
91
|
+
mainEntry = candidate.path
|
|
92
|
+
entryType = candidate.type
|
|
93
|
+
signale.info(`主入口: ${mainEntry}`)
|
|
94
|
+
break
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (!mainEntry) {
|
|
99
|
+
signale.error('无法找到有效的入口文件,请检查以下路径:')
|
|
100
|
+
signale.error(' - src/main-native.ts 或 src/main-native.js')
|
|
101
|
+
signale.error(' - src/main.ts 或 src/main.js')
|
|
102
|
+
signale.error(' - package.json 中的 main 字段')
|
|
103
|
+
process.exit(1)
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
const mainEntryPath = path.resolve(projectRoot, mainEntry)
|
|
@@ -131,11 +139,13 @@ async function main() {
|
|
|
131
139
|
// 如果需要打开浏览器,等待服务器就绪后打开
|
|
132
140
|
if (args.open) {
|
|
133
141
|
const url = `http://localhost:${args.port}`
|
|
134
|
-
waitForServer(url, 30000)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
142
|
+
waitForServer(url, 30000)
|
|
143
|
+
.then(() => {
|
|
144
|
+
openOrRefreshBrowser(url)
|
|
145
|
+
})
|
|
146
|
+
.catch((err) => {
|
|
147
|
+
signale.warn(`自动打开浏览器失败: ${err.message}`)
|
|
148
|
+
})
|
|
139
149
|
}
|
|
140
150
|
|
|
141
151
|
const result = exec(webpackCmd, { stdio: 'inherit' })
|
package/lib/webpack.config.js
CHANGED
|
@@ -111,7 +111,6 @@ module.exports = {
|
|
|
111
111
|
devServer: {
|
|
112
112
|
port,
|
|
113
113
|
hot: true,
|
|
114
|
-
liveReload: true,
|
|
115
114
|
proxy: [
|
|
116
115
|
{
|
|
117
116
|
context: ['/proxy'],
|
|
@@ -139,10 +138,6 @@ module.exports = {
|
|
|
139
138
|
},
|
|
140
139
|
},
|
|
141
140
|
],
|
|
142
|
-
static: {
|
|
143
|
-
directory: path.join(projectRoot, 'public'),
|
|
144
|
-
publicPath: '/',
|
|
145
|
-
},
|
|
146
141
|
client: {
|
|
147
142
|
overlay: { errors: true, warnings: false },
|
|
148
143
|
},
|
|
@@ -281,9 +276,4 @@ module.exports = {
|
|
|
281
276
|
|
|
282
277
|
// 忽略 entry-local.js 中动态 require 的警告(这是预期行为)
|
|
283
278
|
ignoreWarnings: [/Critical dependency: the request of a dependency is an expression/],
|
|
284
|
-
|
|
285
|
-
cache: {
|
|
286
|
-
type: 'filesystem',
|
|
287
|
-
buildDependencies: { config: [__filename] },
|
|
288
|
-
},
|
|
289
279
|
}
|