OFFLINE-GmbH / oc-vite-plugin

Vite integration for October CMS
MIT License
23 stars 9 forks source link

I have wrong paths to assets when I use APP_ENV=local #5

Closed roulendz closed 1 year ago

roulendz commented 1 year ago

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.

<head>
    <link rel="stylesheet" href="https://sb.test/assets/src/css/app.css">
    <script src="https://sb.test/assets/src/js/app.js" type="module"></script>
    <title>Home</title>        
</head>

vite.config.js content

// 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',
        },
    }
})
tobias-kuendig commented 1 year ago

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.