Load page components synchronously

This commit is contained in:
philipp lang 2023-05-20 00:57:05 +02:00
parent 72375affee
commit 234380120e
2 changed files with 8 additions and 7 deletions

10
resources/js/app.js vendored
View File

@ -24,14 +24,14 @@ Vue.use(PiniaVuePlugin);
Vue.component('SvgSprite', () => import('./components/SvgSprite.js'));
Vue.component('ILink', ILink);
// ---------------------------------- mixins -----------------------------------
Vue.mixin(hasModule);
Vue.mixin(hasFlash);
// -------------------------------- Components ---------------------------------
requireModules(require.context('./components/form', false, /\.vue$/, 'lazy'), Vue, 'f');
requireModules(require.context('./components/ui', false, /\.vue$/, 'lazy'), Vue, 'ui');
requireModules(require.context('./components/page', false, /\.vue$/, 'lazy'), Vue, 'page');
requireModules(require.context('./components/page', false, /\.vue$/), Vue, 'page');
// ---------------------------------- mixins -----------------------------------
Vue.mixin(hasModule);
Vue.mixin(hasFlash);
// ----------------------------------- init ------------------------------------
const el = document.getElementById('app');

View File

@ -1,10 +1,11 @@
import {paramCase} from 'change-case';
export default function (context, Vue, prefix) {
var isAsync = context.name === 'webpackAsyncContext';
context.keys().forEach((file) => {
let componentName = paramCase(`${prefix}${file.replace(/^\.\/(.*?)\.vue$/g, '$1')}`);
console.log(componentName);
Vue.component(componentName, () => context(file));
Vue.component(componentName, isAsync ? () => context(file) : context(file).default);
});
}