mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-09-26 22:49:14 +08:00
30 lines
814 B
TypeScript
30 lines
814 B
TypeScript
import webpack from 'webpack'
|
|
import exitHook from 'async-exit-hook'
|
|
import webpackConfig from '../../webpack/webpack.dev'
|
|
import { sendMessage } from './web-socket-server'
|
|
import { defaultWatcherHandler } from './watcher-common'
|
|
|
|
export const startCoreWatcher = () =>
|
|
new Promise<void>(resolve => {
|
|
const compiler = webpack(webpackConfig as webpack.Configuration)
|
|
console.log('本体编译中...')
|
|
const instance = compiler.watch(
|
|
{},
|
|
defaultWatcherHandler(
|
|
() => resolve(),
|
|
result => {
|
|
console.log('本体已编译:', result.hash)
|
|
sendMessage({
|
|
type: 'coreUpdate',
|
|
})
|
|
},
|
|
),
|
|
)
|
|
exitHook(exit =>
|
|
instance.close(() => {
|
|
console.log('本体编译器已退出')
|
|
exit()
|
|
}),
|
|
)
|
|
})
|