preface

As the project gets bigger, the nuxT.J thermal update time gets longer as the project gets bigger. How can we put up with those of us who pursue speed? We have to hit him. Speed it up. The following aspects are used to speed up hot updates in the development process:

  • Use opportunely. Nuxtignore
  • Speed up build speed

configuration

1. Use opportunely. Nuxtignore

The.nuxtignore file is designed to make nuxt.js ignore layout, page, Store, and middleware files in the project root directory during the build package phase. Nuxtignore can be used to speed up hot updates by ignoring page modules developed by other members of the team or by ignoring modules that are not in the development task. Nuxtignore file: nuxtignore file: nuxtignore file

1.1 Create the. Nuxtignore file in the srcDir directory configured for the project

If the project has not configured the srcDir path (which can be found in the nuxt.config.js file in the project), it defaults to the root of the project. If the srcDir path is specified, make sure to create the. Nuxtignore file in the corresponding directory.

1.2 Add modules to be ignored in. Nuxtignore

The file path also takes srcDir as the root path. The file format is as follows:

# ignore pages/foo.vue file pages/foo.vue # Ignore pages/bar/ folder pages/bar/Copy the code

Other more configuration details see: zh.nuxtjs.org/docs/2.x/co…

1.3 Adding.nuxtignore to.gitignore (Done)

The.nuxtignore file should not be committed to a remote repository in order to avoid impacting the project release and the development of other team members. So you need to add.nuxtignore to.gitignore so that it doesn’t commit to the remote repository.

You can add the _nuxtignore file to the root directory for other team members to copy

.gitignore added to the file

Nuxtignore file. NuxtignoreCopy the code

Note: you need to delete the. Nuxtignore file before releasing the local build code, otherwise the files in the build. Nuxtignore will be ignored

2. Build faster

2.1 configuration cache

Increase the build cache. Add the following configuration in nuxt.config.js

export default {
  build: {
    cache: true}}Copy the code

2.2 the parallel configuration

Enable multi-threaded build projects

export default {
  build: {
    parallel: true}}Copy the code

extension

Nuxtignore files (you can also rename them before building and restore them after building) will be ignored. Since we are building a unified server package, this problem can be ignored. If you have friend issued by the local building, can pass nuxt ignore attribute in the configuration: www.nuxtjs.cn/api/configu… Pull different re configurations according to the corresponding environment. This avoids the native build issues introduced above with.nuxtignore.

In addition to nuXT project, other projects can also follow the ideas in this article: not in the development of the function, ignore its function in the development environment, can greatly speed up the development of hot update.