nuxt / vite

⚡ Vite Experience with Nuxt 2
https://vite.nuxtjs.org
1.39k stars 46 forks source link

`vite.base`/ `nuxt.router.base` unsupported #166

Open Patrick-Remy opened 2 years ago

Patrick-Remy commented 2 years ago

Versions

nuxt-vite: v0.1.1 nuxt: v2.15.7

Reproduction

Tbd

Description

If using vite.base option, the build will get broken. But it isn't required as files are properly generated and moved to subdir already by nuxt. Only the router.base option should be reflected in the DEFAULT_APP_TEMPLATE and APP_TEMPLATE.

Update: Unfortunately the build must also be fixed, as if vite.base isn't set any imports in the resulting scripts are using absolute paths.

Previous issue description

This was caused by setting the vite.base option!

I am not sure, if layouts are currently supported by this plugin. The example doesn't have any and in my case I receive the message:

ERROR /src/layouts/error.vue has no corresponding SFC entry in the cache. This is a vite-plugin-vue2 internal error, please open an issue.

This is also the case if I delete this 'layout', the error still exists with path /.nuxt/components/nuxt-error.vue. So I am not sure, if this is work nuxt/vite needs to do (e.g. inject components in layouts dir?) or it

antfu commented 2 years ago

@Patrick-Remy Can you verify if 0.2.x fix this?

Patrick-Remy commented 2 years ago

I can test it in two weeks 👍

Patrick-Remy commented 2 years ago

Yes it works great as expected, thanks for your fast fix.

Patrick-Remy commented 2 years ago

I am sorry, there is still missing base path for vite and nuxt client.js in index.html

    <script type="module" src="/@vite/client"></script>
    <script type="module" src="/_nuxt/client.js"></script>

But it's perfect now for other places, like user-defined resources.

Patrick-Remy commented 2 years ago

Not sure if something like this would fix it: https://github.com/Patrick-Remy/vite/commit/f7a832c3857c9cd4f9cd715e21f048957d51ef9e As I can't test it, when I install the package from my github or local path, it fails with weird require errors.