// themes/your-theme/vite.config.ts
import { defineConfig } from 'vite'
import { resolve, basename } from 'path'
import ViteRestart from 'vite-plugin-restart';
// Your JS/TS/CSS entrypoints.
const input = {
globalJs: resolve(__dirname, 'assets/src/js/app.js'),
indexPageJs: resolve(__dirname, 'pages/index/index.js'),
css: resolve(__dirname, 'assets/src/css/app.css'),
}
// Auto detect the theme name, works only if one theme is available.
const themeName = 'studybook-vite'
export default defineConfig({
// Included assets will use this path as the base URL.
base: `/themes/${themeName}/assets/build/`,
build: {
rollupOptions: { input },
manifest: true,
emptyOutDir: true,
// Output assets to /themes/your-theme/assets/build
outDir: resolve(__dirname, 'assets/build'),
},
server: {
hmr: {
// Do not use encrypted connections for the HMR websocket.
protocol: 'ws',
},
}
})
What URLs are in your generated manifest.json? Are the paths correctly there? If not, the problem has to befixed in your Vite config and is out of the scope of this plugin.
When I use APP_ENV=local I get thease paths in my forntend, how I can fix them? For now I need to set my APP_ENV=production to get them to work.
vite.config.js content