2024-01-03 15:14:09 -05:00
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
import { resolve } from 'path';
|
|
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
import svgrPlugin from 'vite-plugin-svgr';
|
|
|
|
|
|
|
|
const root = resolve(__dirname, 'src');
|
|
|
|
const publicDir = resolve(__dirname, 'public');
|
|
|
|
const outDir = resolve(__dirname, 'build');
|
2023-05-11 18:52:06 -04:00
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
export default defineConfig({
|
2024-01-03 15:14:09 -05:00
|
|
|
root,
|
|
|
|
publicDir,
|
|
|
|
plugins: [
|
|
|
|
react(),
|
|
|
|
svgrPlugin(),
|
|
|
|
{
|
|
|
|
name: 'rewrite-middleware',
|
|
|
|
configureServer(serve) {
|
|
|
|
serve.middlewares.use((req, _res, next) => {
|
|
|
|
if (req.url === '/simple') {
|
|
|
|
req.url = '/simple/';
|
|
|
|
} else if (req.url === '/editorial') {
|
|
|
|
req.url = '/editorial/';
|
|
|
|
}
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
assetsInclude: ['public/**/*'],
|
2023-05-11 18:52:06 -04:00
|
|
|
optimizeDeps: {
|
|
|
|
force: true,
|
2024-01-03 15:14:09 -05:00
|
|
|
include: ['@staticcms/core'],
|
2023-05-11 18:52:06 -04:00
|
|
|
},
|
|
|
|
build: {
|
|
|
|
commonjsOptions: { include: [/core/, /node_modules/] },
|
2024-01-03 15:14:09 -05:00
|
|
|
outDir,
|
|
|
|
emptyOutDir: true,
|
|
|
|
rollupOptions: {
|
|
|
|
input: {
|
|
|
|
main: resolve(root, 'index.html'),
|
|
|
|
simple: resolve(root, 'simple', 'index.html'),
|
|
|
|
editorial: resolve(root, 'editorial', 'index.html'),
|
|
|
|
},
|
|
|
|
},
|
2023-05-11 18:52:06 -04:00
|
|
|
},
|
|
|
|
});
|