How does vue modify the source code of node_modules and the source code of third-party dependent packages

method

Use patch-package to patch the package in node_module to solve the problem of modifying the source code

use

1. Download the patch-package package: npm install patch-package -D

2. Add the command in the package.json file: "postinstall": "patch-package"

{
  "scripts": {
    "serve": " vue-cli-service serve",
    "build": " vue-cli-service build",
    "postinstall": "patch-package"
  }
}

3. Run: npx patch-package zx-layouts (modified package name)

Result: Create patch file

The root directory will automatically generate a patches file to store the modified content, including the modified file location and modification information

Delete node_module, then reinstall the dependencies, and the patch will take effect

The companion pulls the code, including the modified patch file, which will overwrite the source code

Guess you like

Origin blog.csdn.net/m0_61663332/article/details/132139548