I have a simple Vue Hello-world application created via vue-cli. There is the router which should be lazy by default. But as I see in browser network tab it is not lazy. It loads all the components at once on first page load. The only thing I did is add one route to the router. It looks like documentation example. Also as documentation say I have installed @babel/plugin-syntax-dynamic-import and babel.config.js updated. Can somebody tell me please what is the problem?
Here is the router code:
import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'
const routes = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
},
{
path: '/contact',
name: 'Contact',
component: () => import(/* webpackChunkName: "contact" */ '../views/Contact.vue'),
props: {
title: 'Contact',
test: 'Some test value',
}
}
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})
export default router
Here is babel.config.js file
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
],
plugins: [
"@babel/plugin-syntax-dynamic-import"
]
}