57 npm run build 和 npm run serve 的差异

前言

npm run serve 和 npm run build 的差异

这里主要是从 vue-cli 的流程 来看一下 我们经常用到的这两个命令, 他到传递给 webpack 打包的时候, 的一个具体的差异, 大致是配置了那些东西?

经过了那些流程 ?

 

 

vue-cli 的 vue-plugin 的加载

内置的 plugin 列表如下, 依次对应于左边的 commands, config 中的各个 js

也是在这个流程中, npm run serve 和 npm run build 产生了一些配置上的差异 导致了一部分结果的差异

2953f72fc17b4783917899015b7c70b2.png

 

 

vue-cli 的 vue-plugin 的加载导致的差异

更友好的这个json, 可以通过 vue-cli-service inspect 进行查看, 增加 --mode 参数查看不同的环境, 这里是直接调试输出的

npm run serve 执行得到的 webpack 的配置如下

{
  "mode": "development",
  "context": "D:\\WebstormWorkStations\\hello-package",
  "devtool": "eval-cheap-module-source-map",
  "output": {
    "hashFunction": "xxhash64",
    "path": "D:\\WebstormWorkStations\\hello-package\\dist",
    "filename": "js/[name].js",
    "publicPath": "",
    "chunkFilename": "js/[name].js",
    "globalObject": "(typeof self !== 'undefined' ? self : this)"
  },
  "resolve": {
    "alias": {
      "@": "D:\\WebstormWorkStations\\hello-package\\src",
      "vue$": "vue/dist/vue.runtime.esm.js"
    },
    "extensions": [
      ".mjs",
      ".js",
      ".jsx",
      ".vue",
      ".json",
      ".wasm"
    ],
    "modules": [
      "node_modules",
      "D:\\WebstormWorkStations\\hello-package\\node_modules",
      "D:\\WebstormWorkStations\\hello-package\\node_modules\\@vue\\cli-service\\node_modules"
    ]
  },
  "resolveLoader": {
    "modules": [
      "D:\\WebstormWorkStations\\hello-package\\node_modules\\@vue\\cli-plugin-babel\\node_modules",
      "D:\\WebstormWorkStations\\hello-package\\node_modules\\@vue\\cli-service\\lib\\config\\vue-loader-v15-resolve-compat",
      "node_modules",
      "D:\\WebstormWorkStations\\hello-package\\node_modules",
      "D:\\WebstormWorkStations\\hello-package\\node_modules\\@vue\\cli-service\\node_modules"
    ]
  },
  "module": {
    "noParse": {},
    "rules": [
      {
        "test": {},
        "resolve": {
          "fullySpecified": false
        }
      },
      {
        "test": {},
        "use": [
          {
            "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\@vue\\vue-loader-v15\\lib\\index.js",
            "options": {
              "compilerOptions": {
                "whitespace": "condense"
              }
            }
          }
        ]
      },
      {
        "test": {},
        "resourceQuery": {},
        "sideEffects": true
      },
      {
        "test": {},
        "oneOf": [
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "pug-plain-loader"
              }
            ]
          },
          {
            "use": [
              {
                "loader": "raw-loader"
              },
              {
                "loader": "pug-plain-loader"
              }
            ]
          }
        ]
      },
      {
        "test": {},
        "type": "asset/resource",
        "generator": {
          "filename": "img/[name].[hash:8][ext]"
        }
      },
      {
        "test": {},
        "type": "asset",
        "generator": {
          "filename": "img/[name].[hash:8][ext]"
        }
      },
      {
        "test": {},
        "type": "asset",
        "generator": {
          "filename": "media/[name].[hash:8][ext]"
        }
      },
      {
        "test": {},
        "type": "asset",
        "generator": {
          "filename": "fonts/[name].[hash:8][ext]"
        }
      },
      {
        "test": {},
        "oneOf": [
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2,
                  "modules": {
                    "localIdentName": "[name]_[local]_[hash:base64:5]"
                  }
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          },
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          },
          {
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          }
        ]
      },
      {
        "test": {},
        "oneOf": [
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2,
                  "modules": {
                    "localIdentName": "[name]_[local]_[hash:base64:5]"
                  }
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          },
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          },
          {
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          }
        ]
      },
      {
        "test": {},
        "oneOf": [
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2,
                  "modules": {
                    "localIdentName": "[name]_[local]_[hash:base64:5]"
                  }
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          }
        ]
      },
      {
        "test": {},
        "oneOf": [
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2,
                  "modules": {
                    "localIdentName": "[name]_[local]_[hash:base64:5]"
                  }
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false,
                  "sassOptions": {
                    "indentedSyntax": true
                  }
                }
              }
            ]
          },
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false,
                  "sassOptions": {
                    "indentedSyntax": true
                  }
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false,
                  "sassOptions": {
                    "indentedSyntax": true
                  }
                }
              }
            ]
          },
          {
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false,
                  "sassOptions": {
                    "indentedSyntax": true
                  }
                }
              }
            ]
          }
        ]
      },
      {
        "test": {},
        "oneOf": [
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2,
                  "modules": {
                    "localIdentName": "[name]_[local]_[hash:base64:5]"
                  }
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "less-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "less-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "less-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "less-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          }
        ]
      },
      {
        "test": {},
        "oneOf": [
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2,
                  "modules": {
                    "localIdentName": "[name]_[local]_[hash:base64:5]"
                  }
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "stylus-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "stylus-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "stylus-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\vue-style-loader\\index.js",
                "options": {
                  "sourceMap": false,
                  "shadowMode": false
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "stylus-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          }
        ]
      },
      {
        "test": {},
        "exclude": [
          null
        ],
        "use": [
          {
            "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\babel-loader\\lib\\index.js",
            "options": {
              "cacheCompression": false,
              "cacheDirectory": "D:\\WebstormWorkStations\\hello-package\\node_modules\\.cache\\babel-loader",
              "cacheIdentifier": "66c7e3b9"
            }
          }
        ]
      }
    ]
  },
  "optimization": {
    "realContentHash": false,
    "splitChunks": {
      "cacheGroups": {
        "defaultVendors": {
          "name": "chunk-vendors",
          "test": {},
          "priority": -10,
          "chunks": "initial"
        },
        "common": {
          "name": "chunk-common",
          "minChunks": 2,
          "priority": -20,
          "chunks": "initial",
          "reuseExistingChunk": true
        }
      }
    },
    "minimizer": [
      {
        "options": {
          "test": {},
          "extractComments": false,
          "parallel": true,
          "minimizer": {
            "options": {
              "compress": {
                "arrows": false,
                "collapse_vars": false,
                "comparisons": false,
                "computed_props": false,
                "hoist_funs": false,
                "hoist_props": false,
                "hoist_vars": false,
                "inline": false,
                "loops": false,
                "negate_iife": false,
                "properties": false,
                "reduce_funcs": false,
                "reduce_vars": false,
                "switches": false,
                "toplevel": false,
                "typeofs": false,
                "booleans": true,
                "if_return": true,
                "sequences": true,
                "unused": true,
                "conditionals": true,
                "dead_code": true,
                "evaluate": true
              },
              "mangle": {
                "safari10": true
              }
            }
          }
        }
      }
    ]
  },
  "plugins": [
    {},
    {
      "definitions": {
        "process.env": {
          "NODE_ENV": "\"development\"",
          "BASE_URL": "\"\""
        }
      }
    },
    {
      "options": {},
      "logger": {},
      "pathCache": {},
      "fsOperations": 0,
      "primed": false
    },
    {
      "compilationSuccessInfo": {},
      "shouldClearConsole": true,
      "formatters": [
        null,
        null,
        null,
        null
      ],
      "transformers": [
        null,
        null,
        null,
        null
      ],
      "previousEndTimes": {}
    },
    {
      "userOptions": {
        "title": "hello-package",
        "scriptLoading": "defer",
        "template": "D:\\WebstormWorkStations\\hello-package\\public\\index.html"
      },
      "version": 5,
      "options": {
        "template": "D:\\WebstormWorkStations\\hello-package\\public\\index.html",
        "templateContent": false,
        "filename": "index.html",
        "publicPath": "auto",
        "hash": false,
        "inject": "head",
        "scriptLoading": "defer",
        "compile": true,
        "favicon": false,
        "minify": "auto",
        "cache": true,
        "showErrors": true,
        "chunks": "all",
        "excludeChunks": [],
        "chunksSortMode": "auto",
        "meta": {},
        "base": false,
        "title": "hello-package",
        "xhtml": false
      }
    },
    {
      "patterns": [
        {
          "from": "D:\\WebstormWorkStations\\hello-package\\public",
          "to": "D:\\WebstormWorkStations\\hello-package\\dist",
          "toType": "dir",
          "noErrorOnMissing": true,
          "globOptions": {
            "ignore": [
              "**/.DS_Store",
              "D:/WebstormWorkStations/hello-package/public/index.html"
            ]
          },
          "info": {
            "minimized": true
          }
        }
      ],
      "options": {}
    },
    {
      "delegate": {
        "profile": false,
        "modulesCount": 5000,
        "dependenciesCount": 10000,
        "showEntries": false,
        "showModules": true,
        "showDependencies": false,
        "showActiveModules": false,
        "percentBy": "entries"
      }
    }
  ],
  "entry": {
    "app": [
      "./src/main.js"
    ]
  }
}

 

npm run build 执行得到的 webpack 配置如下

{
  "mode": "production",
  "context": "D:\\WebstormWorkStations\\hello-package",
  "devtool": false,
  "output": {
    "hashFunction": "xxhash64",
    "path": "D:\\WebstormWorkStations\\hello-package\\dist",
    "filename": "js/[name].[contenthash:8].js",
    "publicPath": "",
    "chunkFilename": "js/[name].[contenthash:8].js"
  },
  "resolve": {
    "alias": {
      "@": "D:\\WebstormWorkStations\\hello-package\\src",
      "vue$": "vue/dist/vue.runtime.esm.js"
    },
    "extensions": [
      ".mjs",
      ".js",
      ".jsx",
      ".vue",
      ".json",
      ".wasm"
    ],
    "modules": [
      "node_modules",
      "D:\\WebstormWorkStations\\hello-package\\node_modules",
      "D:\\WebstormWorkStations\\hello-package\\node_modules\\@vue\\cli-service\\node_modules"
    ]
  },
  "resolveLoader": {
    "modules": [
      "D:\\WebstormWorkStations\\hello-package\\node_modules\\@vue\\cli-plugin-babel\\node_modules",
      "D:\\WebstormWorkStations\\hello-package\\node_modules\\@vue\\cli-service\\lib\\config\\vue-loader-v15-resolve-compat",
      "node_modules",
      "D:\\WebstormWorkStations\\hello-package\\node_modules",
      "D:\\WebstormWorkStations\\hello-package\\node_modules\\@vue\\cli-service\\node_modules"
    ]
  },
  "module": {
    "noParse": {},
    "rules": [
      {
        "test": {},
        "resolve": {
          "fullySpecified": false
        }
      },
      {
        "test": {},
        "use": [
          {
            "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\@vue\\vue-loader-v15\\lib\\index.js",
            "options": {
              "compilerOptions": {
                "whitespace": "condense"
              }
            }
          }
        ]
      },
      {
        "test": {},
        "resourceQuery": {},
        "sideEffects": true
      },
      {
        "test": {},
        "oneOf": [
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "pug-plain-loader"
              }
            ]
          },
          {
            "use": [
              {
                "loader": "raw-loader"
              },
              {
                "loader": "pug-plain-loader"
              }
            ]
          }
        ]
      },
      {
        "test": {},
        "type": "asset/resource",
        "generator": {
          "filename": "img/[name].[hash:8][ext]"
        }
      },
      {
        "test": {},
        "type": "asset",
        "generator": {
          "filename": "img/[name].[hash:8][ext]"
        }
      },
      {
        "test": {},
        "type": "asset",
        "generator": {
          "filename": "media/[name].[hash:8][ext]"
        }
      },
      {
        "test": {},
        "type": "asset",
        "generator": {
          "filename": "fonts/[name].[hash:8][ext]"
        }
      },
      {
        "test": {},
        "oneOf": [
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2,
                  "modules": {
                    "localIdentName": "[name]_[local]_[hash:base64:5]"
                  }
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          },
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          },
          {
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          }
        ]
      },
      {
        "test": {},
        "oneOf": [
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2,
                  "modules": {
                    "localIdentName": "[name]_[local]_[hash:base64:5]"
                  }
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          },
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          },
          {
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              }
            ]
          }
        ]
      },
      {
        "test": {},
        "oneOf": [
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2,
                  "modules": {
                    "localIdentName": "[name]_[local]_[hash:base64:5]"
                  }
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          }
        ]
      },
      {
        "test": {},
        "oneOf": [
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2,
                  "modules": {
                    "localIdentName": "[name]_[local]_[hash:base64:5]"
                  }
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false,
                  "sassOptions": {
                    "indentedSyntax": true
                  }
                }
              }
            ]
          },
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false,
                  "sassOptions": {
                    "indentedSyntax": true
                  }
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false,
                  "sassOptions": {
                    "indentedSyntax": true
                  }
                }
              }
            ]
          },
          {
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": false,
                  "sassOptions": {
                    "indentedSyntax": true
                  }
                }
              }
            ]
          }
        ]
      },
      {
        "test": {},
        "oneOf": [
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2,
                  "modules": {
                    "localIdentName": "[name]_[local]_[hash:base64:5]"
                  }
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "less-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "less-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "less-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "less-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          }
        ]
      },
      {
        "test": {},
        "oneOf": [
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2,
                  "modules": {
                    "localIdentName": "[name]_[local]_[hash:base64:5]"
                  }
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "stylus-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "resourceQuery": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "stylus-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "test": {},
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "stylus-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          },
          {
            "use": [
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\mini-css-extract-plugin\\dist\\loader.js",
                "options": {
                  "publicPath": "../"
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\css-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "importLoaders": 2
                }
              },
              {
                "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\postcss-loader\\dist\\cjs.js",
                "options": {
                  "sourceMap": false,
                  "postcssOptions": {
                    "plugins": [
                      null
                    ]
                  }
                }
              },
              {
                "loader": "stylus-loader",
                "options": {
                  "sourceMap": false
                }
              }
            ]
          }
        ]
      },
      {
        "test": {},
        "exclude": [
          null
        ],
        "use": [
          {
            "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\thread-loader\\dist\\cjs.js"
          },
          {
            "loader": "D:\\WebstormWorkStations\\hello-package\\node_modules\\babel-loader\\lib\\index.js",
            "options": {
              "cacheCompression": false,
              "cacheDirectory": "D:\\WebstormWorkStations\\hello-package\\node_modules\\.cache\\babel-loader",
              "cacheIdentifier": "47eee831"
            }
          }
        ]
      }
    ]
  },
  "optimization": {
    "realContentHash": false,
    "splitChunks": {
      "cacheGroups": {
        "defaultVendors": {
          "name": "chunk-vendors",
          "test": {},
          "priority": -10,
          "chunks": "initial"
        },
        "common": {
          "name": "chunk-common",
          "minChunks": 2,
          "priority": -20,
          "chunks": "initial",
          "reuseExistingChunk": true
        }
      }
    },
    "minimizer": [
      {
        "options": {
          "test": {},
          "extractComments": false,
          "parallel": true,
          "minimizer": {
            "options": {
              "compress": {
                "arrows": false,
                "collapse_vars": false,
                "comparisons": false,
                "computed_props": false,
                "hoist_funs": false,
                "hoist_props": false,
                "hoist_vars": false,
                "inline": false,
                "loops": false,
                "negate_iife": false,
                "properties": false,
                "reduce_funcs": false,
                "reduce_vars": false,
                "switches": false,
                "toplevel": false,
                "typeofs": false,
                "booleans": true,
                "if_return": true,
                "sequences": true,
                "unused": true,
                "conditionals": true,
                "dead_code": true,
                "evaluate": true
              },
              "mangle": {
                "safari10": true
              }
            }
          }
        }
      },
      {
        "options": {
          "test": {},
          "parallel": true,
          "minimizer": {
            "options": {
              "preset": [
                "default",
                {
                  "mergeLonghand": false,
                  "cssDeclarationSorter": false
                }
              ]
            }
          }
        }
      }
    ]
  },
  "plugins": [
    {},
    {
      "definitions": {
        "process.env": {
          "NODE_ENV": "\"production\"",
          "BASE_URL": "\"\""
        }
      }
    },
    {
      "options": {},
      "logger": {},
      "pathCache": {},
      "fsOperations": 0,
      "primed": false
    },
    {
      "compilationSuccessInfo": {},
      "shouldClearConsole": true,
      "formatters": [
        null,
        null,
        null,
        null
      ],
      "transformers": [
        null,
        null,
        null,
        null
      ],
      "previousEndTimes": {}
    },
    {
      "_sortedModulesCache": {},
      "options": {
        "filename": "css/[name].[contenthash:8].css",
        "ignoreOrder": false,
        "runtime": true,
        "chunkFilename": "css/[name].[contenthash:8].css"
      },
      "runtimeOptions": {
        "linkType": "text/css"
      }
    },
    {
      "userOptions": {
        "title": "hello-package",
        "scriptLoading": "defer",
        "template": "D:\\WebstormWorkStations\\hello-package\\public\\index.html"
      },
      "version": 5,
      "options": {
        "template": "D:\\WebstormWorkStations\\hello-package\\public\\index.html",
        "templateContent": false,
        "filename": "index.html",
        "publicPath": "auto",
        "hash": false,
        "inject": "head",
        "scriptLoading": "defer",
        "compile": true,
        "favicon": false,
        "minify": "auto",
        "cache": true,
        "showErrors": true,
        "chunks": "all",
        "excludeChunks": [],
        "chunksSortMode": "auto",
        "meta": {},
        "base": false,
        "title": "hello-package",
        "xhtml": false
      }
    },
    {
      "patterns": [
        {
          "from": "D:\\WebstormWorkStations\\hello-package\\public",
          "to": "D:\\WebstormWorkStations\\hello-package\\dist",
          "toType": "dir",
          "noErrorOnMissing": true,
          "globOptions": {
            "ignore": [
              "**/.DS_Store",
              "D:/WebstormWorkStations/hello-package/public/index.html"
            ]
          },
          "info": {
            "minimized": true
          }
        }
      ],
      "options": {}
    }
  ],
  "entry": {
    "app": [
      "./src/main.js"
    ]
  }
}

 

我们这里 只是从最终的结果来查看差异, 具体的细节 请参见各个 vue-plugin 的具体的实现

devtool 的默认配置, output 的文件模板存在一些差异

这也就是为什么我们在 npm run serve 的调试中, 看到的各个文件直接是 app.js, src_HelloWorld_vue.js 等等

e80983b03f1d4071892d11269c277aa2.png

 

css 的加载的 loader 有一些差异, npm run serve 是使用 vue-style-loader

npm run build直接使用 mini-css-extract-plugins 最小化目标 css

这里的每一个 test 是表示对于一类模块的加载方式, 只是这里的 test 没有加载出来, 可以理解为这个 test 是一个正则, 总共有十几类, 比如对于 *.vue 文件这样处理方式, *.css 另外的处理方式, 细节 我们不用关心

eb91dc089eac4b5e866efacede361396.png

 

optimization 里面 npm run build 多一个 minimizer 的流程

f09066def1244741b95e10362dc4dc06.png

 

npm run serve 这边多一些 dev 模式下面的一些配置

c040e88365b349fdb05324f51a6aa5b3.png

 

 

关于 plugin 的差异, 这部分的差异也可以在 各个 vue 插件中查找

如下是 npm run serve 的 plugin 列表

811f96a4c17848e9898d564821026635.png

 

如下是 npm run build 的 plugin 列表

0dcf848f7cd9471792677216bde1c180.png

 

比如之前曾经提到过的 CopyPlugin 的注册是在 app.js 中注册的

这个也曾经在 vue 项目默认暴露出去的 public 文件夹 和 CopyWebpackPlugin中提到 

525e0223d8fa4d5ca8e642e7416a9fc5.png

 

 

webpack 的其他上下文导致的差异

注意 这部分代码是在 webpack 里面, 不是在 vue-cli 中

比如, 我就听疑惑 npm run build 和 npm run serve 在哪里配置的一个最小化代码, 一个没有最小化代码? 这个问题 我找了很久, 最后终于找到了

在 webpack/lib/config.defaults.applyOptimizationDefaults 中, 一系列变量是 根据 isProduction 进行初始化的, 这就是为什么 npm run build 的流程中有 minimize 这一项

244a002d22bf44a0a138966d2cbbcb40.png

 

 

npm run serve 使用的内存文件系统, 而 npm run build 打包到磁盘的?

这个流程是由 npm run serve 这边的启动 devServer 的过程触发的

而 npm run build 这边和 devServer 没有关系, 因此 fs 是默认的 磁盘文件系统

26bb87c515714b058d93ad7831da72a0.png

 

具体的配置 outputFileSystem 到 context, compiler 的地方如下

然后可以看到, 这个 outputFileSystem 还是可以自己手动配置的, 扩展性相当强

2595b7b9e0834dea82172b4f4a65e5b1.png

 

 

npm run serve 如何将编译的结果写出到磁盘

其实偶尔也有 npm run servce 的时候, 查看一下具体文件的需求

免得 需要一个调试环境才能够运行时查看 memfs 的文件系统的具体的文件信息

这时候可以通过 devServer 下面的 devMiddleware 的配置进行配置, 增加了一个 writeToDisk 的选项, 这样的话 devServer 这边会将编译的结果, 也写出到内存文件系统, 然后也会写一份数据到磁盘, 服务本身的使用 还是使用 内存文件系统的数据

e57191fae9204ee09101505a58726a14.png

 

这里是通过 webpackDevMiddleware 这里进行关联的

c1eb1459e6be4692ba7196f4cdf4ca83.png

 

这是一份编译完成之后的结果如下

77bb18568fa447858495f6e9b6aff05d.png

 

另外可以通过 options.outputFileSystem 进行配置, 注意看下面 outputFileSystem 部分的配置

e810cfa645ea4ccb9ee757d64f032273.png

 

最终写出的文件信息如下

81057d8452c947c6859ca20dc2c1c1fc.png

 

writeToDisk 参数的文档

d0f3fb68fd8c46ffbb3872d01c6afcd1.png

 

outputFileSystem 参数的文档

8e045860028147bc92b724efe321dc16.png

 

 

完 

 

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/511596.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

使用ffmpeg将视频解码为帧时,图像质量很差

当使用ffmpeg库自带的ffmpeg.exe对对视频进行解帧或合并时,结果质量很差。导致这种原因的是在使用ffmpeg.exe指令进行解帧或合并时使用的是默认的视频码率:200kb/s。 如解帧指令: ffmpeg.exe -i 600600pixels.avi -r 2 -f image2 img/%03d.…

Topaz Video AI for Mac v5.0.0激活版 视频画质增强软件

Topaz Video AI for Mac是一款功能强大的视频处理软件,专为Mac用户设计,旨在通过人工智能技术为视频编辑和增强提供卓越的功能。这款软件利用先进的算法和深度学习技术,能够自动识别和分析视频中的各个元素,并进行智能修复和增强&…

vue 加 websocket 聊天

<template><div style="height: 100%; width: 100%; background-color: #fff"><div class="wrap"><!-- 头部 --><div class="titleBox"><imgsrc="@/assets/image/avatar.png"style="argin: 10p…

windows部署Jenkins并远程部署tomcat

目录 1、Jenkins官网下载Jenkins 2、安装Jenkins 3、修改Home directory 4、插件安装及系统配置 5、Tomcat安装及配置 5.1、修改配置文件,屏蔽以下代码 5.2、新增登录用户 5.3、编码格式修改 5.4、启动tomcat 6、Jenkins远程部署war包 6.1、General配置 6.2、Sourc…

构建开源可观测平台

企业始终面临着确保 IT 基础设施和应用程序全年可用的压力。现代架构&#xff08;容器、混合云、SOA、微服务等&#xff09;的复杂性不断增长&#xff0c;产生大量难以管理的日志。我们需要智能应用程序性能管理 (APM) 和可观察性工具来实现卓越生产并满足可用性和正常运行时间…

ddres( ) 组站星双差方程和设计矩阵

1 ddres( )参数介绍 rtklib中进行的单频解算 双差观测值&#xff0c;单差的模糊度 单频点双差 DD (double-differenced) phase/code residuals ------------------------------ x 模糊度 P 方差-协方差阵 sat 共识卫星列表 ns 共识卫星数量 y…

python爬虫———urllibd的基本操作(第十二天)

&#x1f388;&#x1f388;作者主页&#xff1a; 喔的嘛呀&#x1f388;&#x1f388; &#x1f388;&#x1f388;所属专栏&#xff1a;python爬虫学习&#x1f388;&#x1f388; ✨✨谢谢大家捧场&#xff0c;祝屏幕前的小伙伴们每天都有好运相伴左右&#xff0c;一定要天天…

鸿蒙实战开发-如何使用Stage模型卡片

介绍 本示例展示了Stage模型卡片提供方的创建与使用。 用到了卡片扩展模块接口&#xff0c;ohos.app.form.FormExtensionAbility 。 卡片信息和状态等相关类型和枚举接口&#xff0c;ohos.app.form.formInfo 。 卡片提供方相关接口的能力接口&#xff0c;ohos.app.form.for…

monitor link 联合smart link配合应对复杂的网络

monitor link关键词&#xff1a;上行和下行端口&#xff0c;当上行端口异常&#xff0c;下行端口立即down掉&#xff0c;也就是一种联动机制 如果上行端口里面是smart link方式&#xff0c;则当主从端口都出问题时候&#xff0c;下行端口才会down掉 monitor link 配置步骤 1创…

前端三剑客 —— HTML (下)

目录 HTML 多媒体标签 Img*** a标签*** 第一种用法&#xff1a;超链接 第二种用法&#xff1a;锚点 audio标签 video标签 表格标签 带标题的表格 跨行跨列标签 表格嵌套 列表标签 ul --- 它是无序列表标签 ol --- 它是有序列表 dl --- 它是数据列表 表单标签***…

51单片机学习笔记13 红外遥控接收

51单片机学习笔记13 红外遥控接收 一、红外遥控1. **发射原理**2. **接收原理**3. **发射、接收示例** 二、编码、解码1. **编码方式分类**&#xff1a;&#xff08;1&#xff09;Pulse Distance Modulation (PDM) 脉冲距离调制&#xff1a;&#xff08;2&#xff09;Pulse Wid…

python coding with ChatGPT 专题2| 全解递归算法

文章目录 递归与栈的关系如何思考递归汉诺塔 经典题目入门&#xff1a;斐波那契数列分治法&#xff1a;归并排序树的递归遍历组合问题&#xff1a;子集搜索问题&#xff1a;N皇后 拓展阶乘的迭代法斐波那契数列迭代法青蛙跳 参考文献 掌握递归是解决许多编程问题的关键&#xf…

VBA数据库解决方案第九讲:把数据库的内容在工作表中显示

《VBA数据库解决方案》教程&#xff08;版权10090845&#xff09;是我推出的第二套教程&#xff0c;目前已经是第二版修订了。这套教程定位于中级&#xff0c;是学完字典后的另一个专题讲解。数据库是数据处理的利器&#xff0c;教程中详细介绍了利用ADO连接ACCDB和EXCEL的方法…

如何使用极狐GitLab 启用自动备份功能

本文作者&#xff1a;徐晓伟 GitLab 是一个全球知名的一体化 DevOps 平台&#xff0c;很多人都通过私有化部署 GitLab 来进行源代码托管。极狐GitLab 是 GitLab 在中国的发行版&#xff0c;专门为中国程序员服务。可以一键式部署极狐GitLab。 本文主要讲述了如何极狐GitLab 自…

HarmonyOS 和 OpenHarmony

HarmonyOS 和 OpenHarmony 支持的 shell 命令不同&#xff0c;因此有时候需要做一做区分&#xff0c;目前有些文档上没有标注&#xff0c;因此可能产生歧义。 HarmonyOS 支持 getprop&#xff1a; getprop hw_sc.build.os.apiversion # 查看API版本OpenHarmony 上支持 param…

2024年NAND价格市场继续上涨

TrendForce发布了最新的NAND闪存市场价格走势预测。根据其报告&#xff0c;在2024年第二季度&#xff0c;NAND闪存合同价格将进一步呈现两位数的增长&#xff0c;叠加前一季度的增长。不过&#xff0c;客户端SSD的价格涨幅预计在第二季度将不超过15%&#xff0c;相比于2024年第…

破解密码:掌握2024年的营销归因

Cracking the Code: Mastering Marketing Attribution in 2024 营销归因是识别哪些营销渠道和触及点有助于销售或转化的过程。随着消费者继续通过多个渠道与品牌互动&#xff0c;掌握营销归因对企业来说变得越来越重要。在这篇文章中&#xff0c;我们将探讨破解代码和有效衡量…

PW1503限流芯片:可达3A限流,保障USB电源管理安全高效

在电源管理领域&#xff0c;开关的性能直接关系到设备的稳定性和安全性。今天&#xff0c;我们将详细解析一款备受关注的超低RDS&#xff08;ON&#xff09;开关——PW1503。它不仅具有可编程的电流限制功能&#xff0c;还集成了多项保护机制&#xff0c;为各类电子设备提供了高…

vue两个特性和什么是MVVM

一、什么是vue 1.构建用户界面 用vue往html页面中填充数据&#xff0c;非常的方便 2.框架 框架是一套线成的解决方案 vue的指令、组件&#xff08;是对ui结构的复用&#xff09;、路由、vuex 二、vue的特性 1.数据驱动视图 2.双向数据绑定 1.数据驱动视图 数据的变化会驱动…

基于tensorflow和kereas的孪生网络推理图片相似性

一、环境搭建 基础环境&#xff1a;cuda 11.2 python3.8.13 linux ubuntu18.04 pip install tensorflow-gpu2.11.0 验证&#xff1a;# 查看tensorflow版本 import tensorflow as tf tf.__version__ # 是否能够成功启动GPU from tensorflow.python.client import device_lib pr…