Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy-loading routes, async components #36

Open
rugor opened this issue Oct 26, 2018 · 1 comment
Open

Lazy-loading routes, async components #36

rugor opened this issue Oct 26, 2018 · 1 comment
Labels

Comments

@rugor
Copy link

rugor commented Oct 26, 2018

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:

<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.

@EvanAgee
Copy link
Owner

Awesome, thanks for sharing @rugor

@EvanAgee EvanAgee added the Tip label Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants