cakephp-vite icon indicating copy to clipboard operation
cakephp-vite copied to clipboard

On Windows environments path to assets are broken as they contain incorrect slash

Open K4T opened this issue 2 years ago • 0 comments

Hello, first at all - thank you for your time you used to develop this plugin. Unfortunately today I spotted one problem when I was trying to use it "production" mode.

Generally on Windows environments DS is equal to "\" which should not be used in URLs which are produced by e.g. getLinkFromOutDirectory method.

Like mentioned above, DS is used in e.g. getLinkFromOutDirectory method from ManifestRecord class: https://github.com/brandcom/cakephp-vite/blob/6028e07013a18c079d950ced0d256673b2e5a339/src/Utilities/ManifestRecord.php#L228

to build path to assets like js or css files. This, on Windows, creates following, incorrect URLs like http://test.localhost/js/%5Cassets/main-5de7cc61.js which of course does not load.

Here is my cakephp-vite plugin configuration:

'ViteHelper' => [
    'development' => [
        'scriptEntries' => ['webroot_src/main.js'],
    ],
]

Here is vite.confg.js I am using:

import {defineConfig} from 'vite'

export default defineConfig({
    build: {
        emptyOutDir: false,
        outDir: './webroot',
        manifest: true,
        rollupOptions: {
            input: './webroot_src/main.js',
        },
    },
    server: {
        port: 3000,
        strictPort: true,
        hmr: {
            protocol: 'ws',
            host: 'localhost',
        },
    },
});

K4T avatar Jun 29 '23 08:06 K4T