summaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorHaishan <[email protected]>2021-05-30 16:33:27 +0800
committerHaishan <[email protected]>2021-05-30 17:11:57 +0800
commitcac64c0d2a80105db14ae04e0aeb4eacb148a771 (patch)
tree0471b5af331986b00366856ace236617bcb6c16e /server.js
parentd46ce57be85dc39453cb5668a49ca76e18d6ec7c (diff)
Use vite
Diffstat (limited to 'server.js')
-rw-r--r--server.js62
1 files changed, 0 insertions, 62 deletions
diff --git a/server.js b/server.js
deleted file mode 100644
index f23bda3..0000000
--- a/server.js
+++ /dev/null
@@ -1,62 +0,0 @@
-const path = require('path');
-const config = require('./webpack.config');
-const webpack = require('webpack');
-const express = require('express');
-const app = express();
-
-const devMiddleware = require('webpack-dev-middleware');
-const hotMiddleware = require('webpack-hot-middleware');
-
-const { PORT } = process.env;
-const port = PORT ? Number(PORT) : 3000;
-const publicPath = config.output.publicPath;
-
-config.entry.app.import.unshift('webpack-hot-middleware/client');
-config.plugins.push(
- new webpack.HotModuleReplacementPlugin(),
- new webpack.NoEmitOnErrorsPlugin()
-);
-
-const compiler = webpack(config);
-
-const wdm = devMiddleware(compiler, { publicPath });
-const whm = hotMiddleware(compiler);
-
-app.use(wdm);
-app.use(whm);
-
-app.get('/_dev', (_req, res) => {
- const outputPath = wdm.getFilenameFromUrl(publicPath || '/');
- const filesystem = wdm.fileSystem;
- const content = filesystem.readdirSync(outputPath);
- res.end(content.join('\n'));
-});
-
-app.use('*', (_req, res, next) => {
- const filename = path.join(compiler.outputPath, 'index.html');
- compiler.outputFileSystem.readFile(filename, (err, result) => {
- if (err) return next(err);
-
- res.set('content-type', 'text/html');
- res.send(result);
- res.end();
- });
-});
-
-const host = '0.0.0.0';
-
-app.listen(port, host, () => {
- console.log(`>> Listening at http://${host}:${port}`);
-});
-
-wdm.waitUntilValid(() => {
- console.log(
- `
->> Build ready at:
-
- http://${host}:${port}
- http://127.0.0.1:${port}
- http://localhost:${port}
-`
- );
-});