0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-03-22 11:08:10 +00:00

this should work

This commit is contained in:
Víctor Losada Hernández
2026-02-01 21:59:59 +01:00
parent 71bc95251c
commit 741d7762d8
4 changed files with 7 additions and 10 deletions

View File

@@ -14,8 +14,9 @@
"scripts": {
"dev": "vite",
"build": "vite build && node scripts/compileAssets.js",
"preview": "vite preview",
"preview": "vite preview --port 8000",
"compileAssets": "node scripts/compileAssets.js --dev",
"lint": "eslint --fix",
"lint:dry": "eslint",
"stylelint": "stylelint --fix **/*.{less}",

View File

@@ -10,7 +10,7 @@ async function start() {
if (!isProd) {
vite = await createViteServer({
server: { middlewareMode: 'html' },
server: { middlewareMode: true },
appType: "custom",
});

View File

@@ -574,18 +574,18 @@ export default async function createApp(vite) {
userThemes : req.userThemes
};
console.log('props: ', !!props);
const htmlPath = isProd ? path.resolve('build', 'index.html') : path.resolve('index.html');
let html = fs.readFileSync(htmlPath, 'utf-8');
if(!isProd && vite?.transformIndexHtml) {
html = await vite.transformIndexHtml(req.originalUrl, html);
}
html = html.replace(
'<head>',
`<head><script>window.__INITIAL_PROPS__ = ${JSON.stringify(props)}</script>`
`<head>\n<script id="props" >window.__INITIAL_PROPS__ = ${JSON.stringify(props)}</script>`
);
console.log('html', html);
return html;
};

View File

@@ -9,10 +9,6 @@ export default defineConfig({
outDir: "build",
emptyOutDir: true,
rollupOptions: {
input: {
admin: path.resolve(__dirname, "client/admin/admin.jsx"),
homebrew: path.resolve(__dirname, "client/homebrew/homebrew.jsx"),
},
output: {
entryFileNames: "[name]/bundle.js",
chunkFileNames: "[name]/[name]-[hash].js",