add feed in / out button page and also button to redirect to button page
This commit is contained in:
1 parent
07b8e2dc25
commit
b86bd7a2f4
17 files changed
+719
-28
No files matched your search
+34
-1
@@ -1,15 +1,48 @@
|
||||
/// <reference types="vitest/config" />
|
||||
import path from 'path';
|
||||
import type { Plugin } from 'vite';
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
|
||||
const buttonRoutePlugin = (): Plugin => ({
|
||||
name: 'button-route',
|
||||
configureServer(server) {
|
||||
server.middlewares.use((req, res, next) => {
|
||||
const url = req.url ?? '';
|
||||
const [pathname, search = ''] = url.split('?');
|
||||
const query = search ? `?${search}` : '';
|
||||
|
||||
if (pathname === '/button') {
|
||||
res.statusCode = 301;
|
||||
res.setHeader('Location', `/button/${query}`);
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
if (pathname === '/button/' || pathname === '/button/index.html') {
|
||||
req.url = `/button/index.html${query}`;
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
plugins: [react(), buttonRoutePlugin()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, '.'),
|
||||
},
|
||||
},
|
||||
build: {
|
||||
rollupOptions: {
|
||||
input: {
|
||||
main: path.resolve(__dirname, 'index.html'),
|
||||
button: path.resolve(__dirname, 'button/index.html'),
|
||||
},
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 3001,
|
||||
host: '0.0.0.0',
|
||||
|
||||
Reference in new issue
Block a user