@quicktvui/web-cli 1.0.0-beta.36 → 1.0.0-beta.37
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 +6 -10
- package/lib/entry-package.js +15 -13
- package/lib/webpack.config.js +7 -17
- package/package.json +1 -1
package/bin/qt-web-cli.js
CHANGED
|
@@ -191,22 +191,18 @@ 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
|
-
|
|
204
194
|
server.startCallback((err) => {
|
|
205
195
|
if (err) {
|
|
206
196
|
signale.error('启动开发服务器失败:', err.message)
|
|
207
197
|
process.exit(1)
|
|
208
198
|
}
|
|
209
199
|
signale.success(`开发服务器已启动: http://localhost:${port}`)
|
|
200
|
+
|
|
201
|
+
// 打开浏览器
|
|
202
|
+
if (shouldOpen) {
|
|
203
|
+
const url = `http://localhost:${port}`
|
|
204
|
+
openOrRefreshBrowser(url)
|
|
205
|
+
}
|
|
210
206
|
})
|
|
211
207
|
|
|
212
208
|
// 处理退出信号
|
package/lib/entry-package.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @quicktvui/web-cli - web entry
|
|
2
2
|
// 通过 @quicktvui/web-renderer 导入所有依赖
|
|
3
|
-
//
|
|
3
|
+
// 动态加载主入口,确保初始化顺序正确
|
|
4
4
|
|
|
5
5
|
console.log('[Web Renderer] === Starting initialization ===')
|
|
6
6
|
|
|
@@ -49,15 +49,17 @@ styleEl.textContent = `
|
|
|
49
49
|
document.head.appendChild(styleEl)
|
|
50
50
|
console.log('[Web Renderer] Global CSS reset injected')
|
|
51
51
|
|
|
52
|
-
//
|
|
53
|
-
console.log('[Web Renderer]
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
// 动态加载主入口,等待加载完成后再启动引擎
|
|
53
|
+
console.log('[Web Renderer] Importing main module...')
|
|
54
|
+
import(__QUICKTVUI_MAIN_ENTRY__)
|
|
55
|
+
.then(() => {
|
|
56
|
+
console.log('[Web Renderer] Main module loaded')
|
|
57
|
+
console.log('[Web Renderer] Starting engine...')
|
|
58
|
+
startWebEngine(engine, APP_NAME)
|
|
59
|
+
setTimeout(() => {
|
|
60
|
+
console.log('[Web Renderer] === Initialization complete ===')
|
|
61
|
+
}, 1000)
|
|
62
|
+
})
|
|
63
|
+
.catch((err) => {
|
|
64
|
+
console.error('[Web Renderer] Failed to load main module:', err)
|
|
65
|
+
})
|
package/lib/webpack.config.js
CHANGED
|
@@ -104,14 +104,13 @@ const cssLoader = detectCSSLoader()
|
|
|
104
104
|
const cliDir = path.resolve(__dirname, '..')
|
|
105
105
|
const resolveLoader = (loaderName) => require.resolve(loaderName, { paths: [cliDir] })
|
|
106
106
|
|
|
107
|
-
//
|
|
107
|
+
// 入口文件:只加载 entry-package.js,主入口通过动态 import 加载
|
|
108
108
|
const entryPackageFile = path.resolve(__dirname, 'entry-package.js')
|
|
109
|
-
|
|
110
|
-
const webpackDevServerPath = require.resolve('webpack-dev-server/client', { paths: [cliDir] })
|
|
109
|
+
const entryFiles = ['regenerator-runtime/runtime', entryPackageFile]
|
|
111
110
|
|
|
112
111
|
module.exports = {
|
|
113
112
|
mode: 'development',
|
|
114
|
-
bail:
|
|
113
|
+
bail: true,
|
|
115
114
|
|
|
116
115
|
devServer: {
|
|
117
116
|
port,
|
|
@@ -149,35 +148,26 @@ module.exports = {
|
|
|
149
148
|
},
|
|
150
149
|
|
|
151
150
|
watchOptions: {
|
|
152
|
-
aggregateTimeout:
|
|
153
|
-
poll: 1000,
|
|
151
|
+
aggregateTimeout: 1500,
|
|
152
|
+
poll: 1000,
|
|
154
153
|
ignored: /node_modules/,
|
|
155
154
|
},
|
|
156
155
|
|
|
157
156
|
devtool: 'source-map',
|
|
158
157
|
|
|
159
|
-
//
|
|
160
|
-
// webpack 会按顺序执行入口文件
|
|
158
|
+
// 多入口配置:先加载初始化代码,再加载主入口
|
|
161
159
|
entry: {
|
|
162
|
-
index:
|
|
163
|
-
`${webpackDevServerPath}?http://localhost:${port}`,
|
|
164
|
-
'webpack/hot/dev-server',
|
|
165
|
-
'regenerator-runtime/runtime',
|
|
166
|
-
mainEntry, // 先加载主入口,注册 App
|
|
167
|
-
entryPackageFile, // 再加载初始化代码,启动引擎
|
|
168
|
-
],
|
|
160
|
+
index: entryFiles,
|
|
169
161
|
},
|
|
170
162
|
|
|
171
163
|
output: {
|
|
172
164
|
filename: 'index.bundle.js',
|
|
173
165
|
path: path.resolve(projectRoot, './dist/web/'),
|
|
174
|
-
publicPath: '/',
|
|
175
166
|
strictModuleExceptionHandling: true,
|
|
176
167
|
globalObject: '(0, eval)("this")',
|
|
177
168
|
},
|
|
178
169
|
|
|
179
170
|
plugins: [
|
|
180
|
-
new (require('webpack').HotModuleReplacementPlugin)(),
|
|
181
171
|
new (require('vue-loader').VueLoaderPlugin)(),
|
|
182
172
|
new (require('html-webpack-plugin'))({
|
|
183
173
|
inject: true,
|