A simple Vue MPA example
Setup is pretty easy. The main part is in vue.config.js
, which is where you will write the guidelines for Vue to compile the application as a multi-page application.
Here, I take the example of separating folders into:
assets
: any extra filescomponents
: .vue
componentspages
: set of directories with the pair page.vue
and page.js
, where page.vue
would be the view of the page you want to create and page.js
the JS instructions for this page.Note that if you do a standard installation of CLI VueJS, there will be the pair App.vue
and main.js
. The set of pages I mentioned above, is exactly this pair, repeating itself for each new page you need - including here, I still keep those names.
As I mentioned above, the entire configuration is actually found in vue.config.js
, in the pages
property.
This is where you will register all pages and their data:
entry
: main JS file (aka main.js
)template
: template that this page will use. Here, you can feel free to explore multiple templates and connect them at will to your pages.title
: the title / name of this pagechunks
: if you want to name this pageAfter that, everything is exactly like the normal CLI, and can be customized at will.
I would like to take this space to explain some points:
npm install
npm run serve
npm run build
npm run test
npm run lint
See ‘Configuration Reference‘ on VueJS CLI Official Website.