简体   繁体   中英

Vue.js slow compiling

npm run dev executes very fast.

When I add 1000 rows of html (header) to a .vue file (template), it takes 9 minutes to compile.

Question:

Does vue.js not support such a lengthy template?

Is there any way to speed up?

<template>
  <header class="..." >
    ... (1000 rows)
  </header>
</template>

<script>
export default {
  name: 'Header'
}
</script>

Because you are using a static template with static 1000 html elements. Use v-for !
What it will do is just compile (not run!) the Vue syntax on <template> .
Check this out as well: One Useful Link on Rows Rendering on Different Frameworks

This is caused by prettier eslint.

Solution

Follow this steps to fix it.

  1. goto /node_modules/vue-loader/lib/template-compiler/index.js lines 78:81

  2. Change

    if (!isProduction) {

      code = prettier.format(code, { semi: false })

    } 

to

    // if (!isProduction) { 

      // code = prettier.format(code, { semi: false })

    // }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM