加入服务器对commonjs的支持

This commit is contained in:
AncTe committed 2023-05-13 22:16:51 +08:00
1 parent 72e61ccf41
commit f96ce0f8b0
4 files changed
+47 -8

No files matched your search

+5 -1
View File
@@ -7,6 +7,8 @@ import * as rollup from 'rollup';
import typescript from '@rollup/plugin-typescript';
import rollupBabel from '@rollup/plugin-babel';
import terser from '@rollup/plugin-terser';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
(async function () {
const timestamp = Date.now();
@@ -128,7 +130,9 @@ import terser from '@rollup/plugin-terser';
babelHelpers: 'bundled',
sourceType: 'module'
}),
terser()
terser(),
resolve(),
commonjs()
]
});
await build.write({
+10 -7
View File
@@ -15,6 +15,7 @@ import nodeResolve from '@rollup/plugin-node-resolve';
import EventEmitter from 'events';
import { WebSocket, WebSocketServer } from 'ws';
import chokidar from 'chokidar';
import commonjs from '@rollup/plugin-commonjs';
const base = './public';
@@ -144,10 +145,13 @@ async function getEsmFile(
},
cache: true,
watch: {
exclude: '**/node_modules/**',
buildDelay: 200
exclude: '**/node_modules/**'
},
plugins: [typescript({ sourceMap: true }), nodeResolve()],
plugins: [
typescript({ sourceMap: true }),
nodeResolve(),
commonjs()
],
onwarn() {}
});
@@ -479,7 +483,8 @@ function watchProject() {
'**/_save/**',
/\.min\./,
/(^|[\/\\])\../,
/(^|[\/\\])[^a-zA-Z:\._0-9\/\\]/
/(^|[\/\\])[^a-zA-Z:\._0-9\/\\]/,
/_.*/
]
});
watcher.on('change', async path => {
@@ -514,9 +519,7 @@ function watchProject() {
}
// 剩余内容全部reload
if (!/_.*/.test(path)) {
ws.send(JSON.stringify({ type: 'reload' }));
}
ws.send(JSON.stringify({ type: 'reload' }));
});
}