57 npm run build 和 npm run serve 的差异

news2024/12/24 8:24:49

前言

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

 

 

完 

 

 

 

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

RFID:锂电池自动化产线的智能监护者

RFID:锂电池自动化产线的智能监护者 一个拥有尖端工业科技的黑灯工厂里,自动化技术已经代替大部分的人工,在每天的自动化生产中会有大量的产品问世。但是人员少,自动化多的工厂怎么做生产管理,产品溯源呢?…

FebHost:人工智能时代的新宠儿.AI域名

近年来,人工智能技术在各行各业迅猛发展,正在深刻改变着我们的生活。作为AI领域的专属域名,.AI域名正成为越来越多企业和个人的首选。 那么,.AI域名到底是什么呢?它是一种特殊的顶级域名(Top-Level Domain, TLD),于2013年由 安哥拉政府正式退出。与其他通用顶级域名如.com、.…

【Angular】什么是Angular中的APP_BASE_HREF

1 概述: 在这篇文章中,我们将看到Angular 10中的APP_BASE_HREF是什么以及如何使用它。 APP_BASE_HREF为当前页面的基础href返回一个预定义的DI标记。 APP_BASE_HREF是应该被保留的URL前缀。 2 语法: provide: APP_BASE_HREF, useValue: /gfgapp3 步骤: 在app.m…

dataloader numworkers

numworkers是加载数据的额外cpu数量(也可以看成额外的进程)。可以理解是: dataset中的getitem只能得到单个数据, 而numworker设置后是同时加载numwork个数据到RAM中,当需要数据时,不会重新执行getiem的方法…

鸿蒙OS元服务开发:【(Stage模型)设置应用主窗口】

一、设置应用主窗口说明 在Stage模型下,应用主窗口由UIAbility创建并维护生命周期。在UIAbility的onWindowStageCreate回调中,通过WindowStage获取应用主窗口,即可对其进行属性设置等操作。还可以在应用配置文件中设置应用主窗口的属性&…

使用docker-tc对host容器进行限流

docker-tc是一个github开源项目,项目地址是https://github.com/lukaszlach/docker-tc。 运行docker-tc docker run -d \ --name docker-tc \ --network host \ --cap-add NET_ADMIN \ --restart always \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /var…

上位机图像处理和嵌入式模块部署(qmacviusal边缘宽度测量)

【 声明:版权所有,欢迎转载,请勿用于商业用途。 联系信箱:feixiaoxing 163.com】 前面有一篇文章,我们了解了测量标定是怎么做的。即,我们需要提前知道测量的方向,灰度的方向,实际的…

【Error】log依赖冲突

启动项目报错: 原因: web模块存在两个log依赖,存在冲突 解决方案: 使用依赖分析插件删除多出的依赖:

蓝桥杯 - 走迷宫

解题思路: 经典dfs题目,需要重点掌握。 养成好习惯,静态方法都要用到的变量提前想到定义为静态常量。 import java.util.Scanner;public class Main {//注意加static,经常忘记导致编译错误static int N, M, x1, x2, y1, y2, mi…

总结jvm中GC机制(垃圾回收)

前言 本篇博客博主将介绍jvm中的GC机制,坐好板凳发车啦~~ 一.GC相关 1.1回收栈内存 对于虚拟机栈,本地方法栈这部分区域而言,其生命周期与相关线程相关,随线程而生,随线程而灭。并且这三个区域的内存分配与回收具有…

房间预定小程序怎么做_打造用户的专属空间预定小程序

在这个快节奏的时代,人们对于便捷、高效的生活方式有着越来越高的追求。无论是出差、旅行还是日常生活,一个好的住宿环境都是必不可少的。然而,传统的房间预定方式往往让人头疼不已,电话沟通、排队等待、繁琐的手续……这些问题不…

Flutter开发之图片选择器

使用FLutter开发了一个图片选择的组件,功能如下: 1、支持设置最大可选图片的个数; 2、根据选择的图片个数自适应容器组件的高度; 3、可设置容器的最大高度; 4、支持点击放大和删除功能; 具体效果如下 …

Java解析实体类的属性和属性注释

前言 获取某个类的属性(字段)是我们经常都会碰到的,通常我们是通过反射来获取的。 但是有些特殊情况下,我们不仅要获取类的属性,还需要获取属性注释。这种情况下,我们只能通过注解去获取注释。可以自己定…

Photoshop 2024 Mac/win---图像处理的新纪元,解锁无限创意

Photoshop 2024是一款功能强大的图像处理软件,以其卓越的性能和广泛的应用领域,赢得了设计师、摄影师、图形艺术家等各类创意工作者的青睐。它提供了丰富的绘画和编辑工具,让用户能够轻松进行图片编辑、合成、校色、抠图等操作,实…

DevOps与CI/CD简介

DevOps 是一种软件开发和运维的文化、实践和方法论,旨在通过加强开发团队和运维团队之间的合作和沟通,实现快速、高效、可靠的软件交付和运维。DevOps 是由 Development(开发)和 Operations(运维)两个单词组…

如何才能实现基坑自动化监测?

基坑自动化监测是一个系统性的过程,它涉及对基坑整体情况的全面了解和分析,确定监测指标,选择合适的监测传感器并进行安装和调试,配置相应的数据采集、传输和管理软件系统,以及进行系统的调试、定期维护和数据分析。以…

抖音视频关键词批量下载工具|视频爬虫采集软件

抖音视频批量提取工具,搜索即下载,轻松获取所需视频! 正文: 想要轻松获取抖音上的精彩视频吗?现在,有了我们的抖音视频批量提取工具,一切变得简单易行!Q:290615413无论是针对特定关…

list使用与模拟实现

目录 list使用 reverse sort unique splice list模拟实现 类与成员函数声明 节点类型的定义 非const迭代器的实现 list成员函数 构造函数 尾插 头插 头删 尾删 任意位置插入 任意位置删除 清空数据 析构函数 拷贝构造函数 赋值重载函数 const迭代器的设计 …

Unity自定义框架(1)-----------单例模式

前言: Unity作为一款强大的游戏开发引擎,其基础框架的设计对于项目的结构和性能有着重要的影响。其中,单例模式是一种常用的设计模式,用于确保一个类只有一个实例,并提供一个全局访问点。 什么是单例模式&#xff1f…

C++面向对象程序设计 - 构造函数

C提供了构造函数来处理对象的初始化,构造函数是一种特殊的成员函数,与其他成员函数不同,它不需要用户来调用,而是在建立对象时自动执行。构造函数名称必须与类同名,而不能由用户任意命名,以便编译系统能识别…