I am working on a project which has different vuejs app instances like.
main-project
> app1
> src
> build
-- main.js
-- App.vue
-- package.json
> app2
> src
> build
-- main.js
-- App.vue
-- package.json
> app3
> src
> build
-- main.js
-- App.vue
-- package.json
.
.
.
.
I have created these app using vue-cli
: vue init webpack app1
, vue init webpack app2
and so on. When I build these apps using webpack
I got following files
main-project
> dist
> assets
> app1
-- app.css
-- vendor.js
-- app.js
-- manifest.js
> app2
-- app.css
-- vendor.js
-- app.js
-- manifest.js
> app3
-- app.css
-- vendor.js
-- app.js
-- manifest.js
-- app1.html
-- app2.html
-- app3.html
.
.
.
.
There are 3 (or more apps..) have different components eg. Let us say app2 is only for mobile and it has all components different in such a way that these are not used (can't be used) in other apps. So now as long as the no of app is less in number this approach seems ok. But when no of apps grow in size this will create same file multiple type like package.json node_modules and so on And this will result in increase in the project file size unnecessary.
Now my question is how to organize this in such a way that I can use same package.json and node_modules (same files across different apps) from a single folder like:
main-project
> apps
> src
> build
-- package.json
-- main1.js
-- App1.vue
-- main2.js
-- App2.vue
-- main3.js
-- App3.vue
.
.
.
.
and after build these for production
main-project
> dist
> assets
> app1
-- app.css
-- vendor.js
-- app.js
-- manifest.js
> app2
-- app.css
-- vendor.js
-- app.js
-- manifest.js
> app3
-- app.css
-- vendor.js
-- app.js
-- manifest.js
-- app1.html
-- app2.html
-- app3.html
.
.
.
.
It is totally legal and fine to have multiple Vue instances on your page controlling different parts and pieces of it. In fact, you can even have your instances communicate with each other by storing them in variables within the global namespace.
Vue. js 3 is a solid framework for building applications both large and small.
Running the app locallyThe Vue CLI comes with a built-in development server. This allows you to run your app locally so you can test it easily without needing to configure a server yourself.
I used the Vue Cli Pages.
//vue.config.js
module.exports = {
pages: {
app1: {
entry: 'src/app1/main.js',
template: 'public/index.html',
filename: 'App1.html',
title: 'App number one',
chunks: ['chunk-vendors', 'rather-than-package-json', 'index'],
},
app2: {
entry: 'src/app2/main.js',
template: 'public/index.html',
filename: 'App2.html',
title: 'App number tow',
chunks: ['chunk-vendors', 'any-other-chunk', 'index'],
},
//...
},
//...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With