Load page components synchronously
This commit is contained in:
parent
72375affee
commit
234380120e
|
@ -24,14 +24,14 @@ Vue.use(PiniaVuePlugin);
|
||||||
Vue.component('SvgSprite', () => import('./components/SvgSprite.js'));
|
Vue.component('SvgSprite', () => import('./components/SvgSprite.js'));
|
||||||
Vue.component('ILink', ILink);
|
Vue.component('ILink', ILink);
|
||||||
|
|
||||||
// ---------------------------------- mixins -----------------------------------
|
|
||||||
Vue.mixin(hasModule);
|
|
||||||
Vue.mixin(hasFlash);
|
|
||||||
|
|
||||||
// -------------------------------- Components ---------------------------------
|
// -------------------------------- Components ---------------------------------
|
||||||
requireModules(require.context('./components/form', false, /\.vue$/, 'lazy'), Vue, 'f');
|
requireModules(require.context('./components/form', false, /\.vue$/, 'lazy'), Vue, 'f');
|
||||||
requireModules(require.context('./components/ui', false, /\.vue$/, 'lazy'), Vue, 'ui');
|
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 ------------------------------------
|
// ----------------------------------- init ------------------------------------
|
||||||
const el = document.getElementById('app');
|
const el = document.getElementById('app');
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import {paramCase} from 'change-case';
|
import {paramCase} from 'change-case';
|
||||||
|
|
||||||
export default function (context, Vue, prefix) {
|
export default function (context, Vue, prefix) {
|
||||||
|
var isAsync = context.name === 'webpackAsyncContext';
|
||||||
|
|
||||||
context.keys().forEach((file) => {
|
context.keys().forEach((file) => {
|
||||||
let componentName = paramCase(`${prefix}${file.replace(/^\.\/(.*?)\.vue$/g, '$1')}`);
|
let componentName = paramCase(`${prefix}${file.replace(/^\.\/(.*?)\.vue$/g, '$1')}`);
|
||||||
|
|
||||||
console.log(componentName);
|
Vue.component(componentName, isAsync ? () => context(file) : context(file).default);
|
||||||
Vue.component(componentName, () => context(file));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue