Open rugor opened 5 years ago
Code splitting minimizes bundle size, so I wanted it for my project. This is how I did it:
in router/index.js:
// import Page from '../components/Page/Page.vue' const Page = () => import('../components/Page/Page.vue')
in webpack.mix.js:
mix.webpackConfig({ output: { publicPath: 'vuejs-wordpress-theme-starter/dist/', chunkFilename: 'scripts/[name].[chunkhash].js', }, });
and in the <head> of index.php:
<head>
<base href="<?php bloginfo( 'stylesheet_directory' ); ?>" />
Not sure if lazy-loading is 'best practice' for everyone, so putting it here instead of a pr. Perhaps its useful for someone or can be improved.
Awesome, thanks for sharing @rugor
Code splitting minimizes bundle size, so I wanted it for my project. This is how I did it:
in router/index.js:
in webpack.mix.js:
and in the
<head>
of index.php:<base href="<?php bloginfo( 'stylesheet_directory' ); ?>" />
Not sure if lazy-loading is 'best practice' for everyone, so putting it here instead of a pr. Perhaps its useful for someone or can be improved.