ui: use sharedworker for messages conn

This commit is contained in:
undefined committed 2022-02-03 21:09:32 +08:00
1 parent b0f1c0d52c
commit a2d5996311
8 files changed
+102 -13

No files matched your search

+13 -3
View File
@@ -2,6 +2,7 @@
import cac from 'cac';
import fs from 'fs-extra';
import webpack from 'webpack';
import esbuild from 'esbuild';
import WebpackDevServer from 'webpack-dev-server';
import gulp from 'gulp';
import log from 'fancy-log';
@@ -13,9 +14,18 @@ import webpackConfig from './config/webpack';
const argv = cac().parse();
function runWebpack({
async function runWebpack({
watch, production, measure, dev,
}) {
const result = esbuild.build({
bundle: true,
format: 'iife',
entryPoints: [root('sharedworker.ts')],
outfile: root('.build/sharedworker.js'),
watch: dev || watch,
minify: production,
});
if (!dev && !watch) await result;
const compiler = webpack(webpackConfig({ watch, production, measure }));
if (dev) {
const server = new WebpackDevServer(compiler, {
@@ -23,9 +33,9 @@ function runWebpack({
hot: true,
disableHostCheck: true,
stats: 'none',
index: '',
index: root('public'),
proxy: {
context: () => true,
context: (path) => !path.includes('sharedworker.js'),
target: 'http://localhost:2333',
ws: true,
},