@quicktvui/web-cli 1.0.0-beta.28 → 1.0.0-beta.29
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 +10 -6
- package/package.json +1 -1
package/bin/qt-web-cli.js
CHANGED
|
@@ -191,18 +191,22 @@ function startDevServer(configPath, port, shouldOpen) {
|
|
|
191
191
|
const compiler = webpack(config)
|
|
192
192
|
const server = new WebpackDevServer(config.devServer, compiler)
|
|
193
193
|
|
|
194
|
+
// 监听编译完成事件,在首次编译完成后打开浏览器
|
|
195
|
+
let isOpened = false
|
|
196
|
+
compiler.hooks.done.tap('open-browser', (stats) => {
|
|
197
|
+
if (!isOpened && shouldOpen) {
|
|
198
|
+
isOpened = true
|
|
199
|
+
const url = `http://localhost:${port}`
|
|
200
|
+
openOrRefreshBrowser(url)
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
|
|
194
204
|
server.startCallback((err) => {
|
|
195
205
|
if (err) {
|
|
196
206
|
signale.error('启动开发服务器失败:', err.message)
|
|
197
207
|
process.exit(1)
|
|
198
208
|
}
|
|
199
209
|
signale.success(`开发服务器已启动: http://localhost:${port}`)
|
|
200
|
-
|
|
201
|
-
// 打开浏览器
|
|
202
|
-
if (shouldOpen) {
|
|
203
|
-
const url = `http://localhost:${port}`
|
|
204
|
-
openOrRefreshBrowser(url)
|
|
205
|
-
}
|
|
206
210
|
})
|
|
207
211
|
|
|
208
212
|
// 处理退出信号
|