Answer the question
In order to leave comments, you need to log in
How to correctly include a Vue component depending on an environment variable?
Hello.
There is a Vue application that is the same for both web and mobile. That is, I can assemble it both for publishing as a site and for use as a mobile webview application.
During the build, for both, I use an environment variable, and already in the code, depending on its value, I include certain components. Example:
{
path: '/chat',
name: 'chats',
component: isWeb() ? Messages : ChatListMobile,
children: [
{
path: ':id',
name: 'chat',
component: () => import('./inc/MessagesBody'),
meta: {
auth,
},
},
],
meta: {
middleware: [
auth,
],
animation: true,
},
},
export function isWeb() {
return process.env.VUE_APP_PLATFORM === 'web';
}
Uncaught (in promise) TypeError: Object(...) is not a function.
configureWebpack: {
resolve: {
alias: {
'vue$': 'vue/dist/vue.js',
},
},
},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question