diff --git a/resources/js/app.js b/resources/js/app.js index aadfeced..252d14ba 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -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'); diff --git a/resources/js/lib/requireModules.js b/resources/js/lib/requireModules.js index 85b1ceaf..7ef50c39 100644 --- a/resources/js/lib/requireModules.js +++ b/resources/js/lib/requireModules.js @@ -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); }); }