quasar-app-extension-auto-routing
quasar-app-extension-auto-routing copied to clipboard
RouterLayout should be Generated named static import instead of dynamic import for Vite.
Quasar with Webpack is still working without problem. but, when I using Vite, it's not working. Due to lack of supported dynamic routes on Rollup, layout will not exposed, so Quasar with Vite will render nothing. but if it generate as named dynamic static import like this:
const RouterLayout = createRouterLayout(layout => {
switch(layout) { // or plain object or more something template that awesome...
// user created layout files:
case 'some': return import('layouts/some.vue');
case 'other': return import('layouts/other.vue');
// default layout:
default: return import('layouts/default.vue'); // or as configure
}
})
I think it will works like charm even using Vite. If you not excused, I'll make a pull request after test.
Oh wonderful! Thanks for being proactive :+1:
absolutely, pr is welcome :)
Coming from Nuxt, I really like this extension, but the issue raised above still seems to be unresolved. I'd prefer to use Vite over Webpack, but as it stands, I'll either have to go back to manual routing or switch to Webpack.
I tried adding @rollup/plugin-dynamic-import-vars and configuring it with import dynamicImportVars from '@rollup/plugin-dynamic-import-vars';
export default { plugins: [ dynamicImportVars({ include: ['../src/layouts/*.vue'] }) ] };
I still get the error:
[vite] warning:
/Users/user/Projects/memberportalq/src/router/auto-routing/index.js
4 |
5 | const RouterLayout = createRouterLayout(layout => {
6 | return import('/Users/user/Projects/memberportalq/src/layouts/' + layout + '.vue')
| ^
7 | })
8 |
The above dynamic import cannot be analyzed by vite.
See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats. If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.
Plugin: vite:import-analysis File: /Users/user/Projects/memberportalq/src/router/auto-routing/index.js
Any news on that? @composite ? I can't use the plugin because of this problem.