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 产生了一些配置上的差异 导致了一部分结果的差异

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 等等

css 的加载的 loader 有一些差异, npm run serve 是使用 vue-style-loader
npm run build直接使用 mini-css-extract-plugins 最小化目标 css
这里的每一个 test 是表示对于一类模块的加载方式, 只是这里的 test 没有加载出来, 可以理解为这个 test 是一个正则, 总共有十几类, 比如对于 *.vue 文件这样处理方式, *.css 另外的处理方式, 细节 我们不用关心

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

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

关于 plugin 的差异, 这部分的差异也可以在 各个 vue 插件中查找
如下是 npm run serve 的 plugin 列表

如下是 npm run build 的 plugin 列表

比如之前曾经提到过的 CopyPlugin 的注册是在 app.js 中注册的
这个也曾经在 vue 项目默认暴露出去的 public 文件夹 和 CopyWebpackPlugin中提到

webpack 的其他上下文导致的差异
注意 这部分代码是在 webpack 里面, 不是在 vue-cli 中
比如, 我就听疑惑 npm run build 和 npm run serve 在哪里配置的一个最小化代码, 一个没有最小化代码? 这个问题 我找了很久, 最后终于找到了
在 webpack/lib/config.defaults.applyOptimizationDefaults 中, 一系列变量是 根据 isProduction 进行初始化的, 这就是为什么 npm run build 的流程中有 minimize 这一项

npm run serve 使用的内存文件系统, 而 npm run build 打包到磁盘的?
这个流程是由 npm run serve 这边的启动 devServer 的过程触发的
而 npm run build 这边和 devServer 没有关系, 因此 fs 是默认的 磁盘文件系统

具体的配置 outputFileSystem 到 context, compiler 的地方如下
然后可以看到, 这个 outputFileSystem 还是可以自己手动配置的, 扩展性相当强

npm run serve 如何将编译的结果写出到磁盘
其实偶尔也有 npm run servce 的时候, 查看一下具体文件的需求
免得 需要一个调试环境才能够运行时查看 memfs 的文件系统的具体的文件信息
这时候可以通过 devServer 下面的 devMiddleware 的配置进行配置, 增加了一个 writeToDisk 的选项, 这样的话 devServer 这边会将编译的结果, 也写出到内存文件系统, 然后也会写一份数据到磁盘, 服务本身的使用 还是使用 内存文件系统的数据

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

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

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

最终写出的文件信息如下

writeToDisk 参数的文档

outputFileSystem 参数的文档

完
相关文章:
57 npm run build 和 npm run serve 的差异
前言 npm run serve 和 npm run build 的差异 这里主要是从 vue-cli 的流程 来看一下 我们经常用到的这两个命令, 他到传递给 webpack 打包的时候, 的一个具体的差异, 大致是配置了那些东西? 经过了那些流程 ? vue-cli 的 vue-plugin 的加载 内置的 plugin 列表如下, 依次…...
原生小程序开发性能优化指南
性能优化指南 1.骨架屏 业务可以在数据加载完成之前用骨架屏幕来占位,提升体验。 2.包大小优化 减小包中静态资源,例如图片文件,可将图片进行压缩降低文件体积。无用文件、函数、样式剔除。除了部分用于容错的图片必须放在代码包…...
「51媒体网」邀请媒体采访报道对企业宣传有何意义?
传媒如春雨,润物细无声的,大家好,我是51媒体网胡老师。 邀请媒体采访报道对企业宣传具有多重意义: 提升品牌知名度和曝光度:媒体是信息传播的重要渠道,通过媒体的报道,企业及其活动、产品能够迅…...
用动态IP采集数据总是掉线是为什么?该怎么解决?
动态IP可以说是做爬虫、采集数据、搜集热门商品信息中必备的代理工具,但在爬虫的使用中,总是会遇到动态IP掉线的情况,从而影响使用效率,本文将探讨动态IP代理掉线的几种常见原因,并提供解决方法,以帮助大家…...
MySQL操作DDL
目录 1.概述 2.数据库的增删改查 3.表的增删改查 3.1.创建和查看表结构 3.2.修改表 3.3.查看所有的表 3.4.删除表 4.用户 5.DDL在实际应用场景中的作用 5.1.数据库设计 5.2.数据库维护 5.3.数据库迁移或重置 5.4.优化性能 …...
程序员如何搞副业
目录 1.概述 2.个人项目开发 3.在线教育和培训 4.技术博客和内容创作 1.概述 程序员通过副业实现个人价值最大化和增加收入的途径多种多样,以下是一些方法: 自由职业: 程序员可以在业余时间提供自由职业服务。包括为客户开发软件、网站或应用程序、…...
【嵌入式开发 Linux 常用命令系列 4.3 -- git add 不 add untracked file】
请阅读【嵌入式开发学习必备专栏 】 文章目录 git add 不add untracked file git add 不add untracked file 如果你想要Git在执行git add .时不添加未跟踪的文件(untracked files),你可以使用以下命令: git add -u这个命令只会加…...
git 常用命令和使用方法
作者简介: 一个平凡而乐于分享的小比特,中南民族大学通信工程专业研究生在读,研究方向无线联邦学习 擅长领域:驱动开发,嵌入式软件开发,BSP开发 作者主页:一个平凡而乐于分享的小比特的个人主页…...
程序员如何搞副业?
程序员不仅拥有将抽象概念转化为实际应用的能力,还通常具备强大的逻辑思维和问题解决能力。然而,许多程序员并不满足于仅仅在一家公司工作,他们渴望通过副业来实现个人价值的最大化,增加收入,甚至探索自己的创业梦想。…...
深入浅出 -- 系统架构之负载均衡Nginx实现高可用
一、Nginx的高可用 线上如果采用单个节点的方式部署Nginx,难免会出现天灾人祸,比如系统异常、程序宕机、服务器断电、机房爆炸、地球毁灭....哈哈哈,夸张了。但实际生产环境中确实存在隐患问题,由于Nginx作为整个系统的网关层接入…...
鲸鱼优化算法(Whale Optimization Algorithm)
注意:本文引用自专业人工智能社区Venus AI 更多AI知识请参考原站 ([www.aideeplearning.cn]) 算法背景 鲸鱼优化算法(Whale Optimization Algorithm, WOA)是一种模拟鲸鱼捕食行为的优化算法。想象一下,你…...
C++内存管理new-delete大法及实现原理
目录 前言: 一:C语言中区域划分的回顾及各个变量存在的位置 1.经典例题 编辑2.C/C中内存区域的划分 二:C内存管理方式 new delete操作符 1.对于内置类型 2.对于自定义类型 三:operator new和operator delete函数 1…...
Spring WebFlux响应式实现WebFilter解决跨域问题
WebFilter 是 Spring Framework 中用于处理 Web 请求的过滤器接口,它是在基于 Servlet 3.0 规范的基础上,为了支持响应式编程模型而引入的。与传统的 Servlet 过滤器相似,WebFilter 也允许开发者对进入的请求和返回的响应进行拦截、修改或者增…...
第4章 Redis,一站式高性能存储方案,笔记问题
点赞具体要实现功能有哪些? 可以点赞的地方:对帖子点赞,对评论点赞点一次是点赞,再点一次是取消赞统计点赞的数量(计数,string),帖子被点赞的数量,某个用户被点赞的数量…...
UVA540 Team Queue 解题报告
UVA540 Team Queue 解题报告 题目链接 https://vjudge.net/problem/UVA-540 题目大意 有t个团队的人正在排一个长队。每次新来一个人时,如果他有队友在排队,那么这个新人会插队到最后一个队友的身后。如果没有任何一个队友排队,则他会排到…...
基础贪心问题
1.部分背包问题 #include<iostream> #include<algorithm> using namespace std; const int N 110; double v[N], w[N]; pair<double, int> a[N]; int n, m;int main(){cin>>n>>m;double x, y;for(int i 0; i < n; i){cin>>v[i]>&g…...
day13 java final 类和对象的初始化执行顺序
final [面试题]请简述final关键字final修饰类(最终的类)-太监类:该类不能被继承。(比如:String StringBuilder,....) final修饰方法(最终的方法):不能被重写 final修饰的变量 :值不…...
蓝桥杯gcd汇总
gcd3014 问题描述 小明和小红是一对恋人,他们相爱已经三年了,在今年的七夕节,小明准备给小红一个特殊的礼物。他想要送给小红一些数字,让小红算出有多少对正整数 (a,b) 满足以下条件: clcm(a,b)−dgcd(a,b)x其中 c,…...
极市平台 | 综述:一文详解50多种多模态图像融合方法
本文来源公众号“极市平台”,仅用于学术分享,侵权删,干货满满。 原文链接:综述:一文详解50多种多模态图像融合方法 0 极市导读 本工作总结了50篇论文中Lidar和camera的多模态融合的一些概念方法。笔者结合原文以及自…...
数据结构系列-队列的结构和队列的实现
🌈个人主页:羽晨同学 💫个人格言:“成为自己未来的主人~” 队列 队列的概念及结构 队列:只允许在一端进行插入数据操作,在另一端进行删除删除数据操作的特殊线性表,队列具有先进先出FIFO,…...
基于距离变化能量开销动态调整的WSN低功耗拓扑控制开销算法matlab仿真
目录 1.程序功能描述 2.测试软件版本以及运行结果展示 3.核心程序 4.算法仿真参数 5.算法理论概述 6.参考文献 7.完整程序 1.程序功能描述 通过动态调整节点通信的能量开销,平衡网络负载,延长WSN生命周期。具体通过建立基于距离的能量消耗模型&am…...
spring:实例工厂方法获取bean
spring处理使用静态工厂方法获取bean实例,也可以通过实例工厂方法获取bean实例。 实例工厂方法步骤如下: 定义实例工厂类(Java代码),定义实例工厂(xml),定义调用实例工厂ÿ…...
css3笔记 (1) 自用
outline: none 用于移除元素获得焦点时默认的轮廓线 broder:0 用于移除边框 font-size:0 用于设置字体不显示 list-style: none 消除<li> 标签默认样式 margin: xx auto 版心居中 width:100% 通栏 vertical-align 作用于行内元素 / 表格单元格ÿ…...
聊一聊接口测试的意义有哪些?
目录 一、隔离性 & 早期测试 二、保障系统集成质量 三、验证业务逻辑的核心层 四、提升测试效率与覆盖度 五、系统稳定性的守护者 六、驱动团队协作与契约管理 七、性能与扩展性的前置评估 八、持续交付的核心支撑 接口测试的意义可以从四个维度展开,首…...
AGain DB和倍数增益的关系
我在设置一款索尼CMOS芯片时,Again增益0db变化为6DB,画面的变化只有2倍DN的增益,比如10变为20。 这与dB和线性增益的关系以及传感器处理流程有关。以下是具体原因分析: 1. dB与线性增益的换算关系 6dB对应的理论线性增益应为&…...
JavaScript 数据类型详解
JavaScript 数据类型详解 JavaScript 数据类型分为 原始类型(Primitive) 和 对象类型(Object) 两大类,共 8 种(ES11): 一、原始类型(7种) 1. undefined 定…...
Redis:现代应用开发的高效内存数据存储利器
一、Redis的起源与发展 Redis最初由意大利程序员Salvatore Sanfilippo在2009年开发,其初衷是为了满足他自己的一个项目需求,即需要一个高性能的键值存储系统来解决传统数据库在高并发场景下的性能瓶颈。随着项目的开源,Redis凭借其简单易用、…...
iview框架主题色的应用
1.下载 less要使用3.0.0以下的版本 npm install less2.7.3 npm install less-loader4.0.52./src/config/theme.js文件 module.exports {yellow: {theme-color: #FDCE04},blue: {theme-color: #547CE7} }在sass中使用theme配置的颜色主题,无需引入,直接可…...
为什么要创建 Vue 实例
核心原因:Vue 需要一个「控制中心」来驱动整个应用 你可以把 Vue 实例想象成你应用的**「大脑」或「引擎」。它负责协调模板、数据、逻辑和行为,将它们变成一个活的、可交互的应用**。没有这个实例,你的代码只是一堆静态的 HTML、JavaScript 变量和函数,无法「活」起来。 …...
Rust 开发环境搭建
环境搭建 1、开发工具RustRover 或者vs code 2、Cygwin64 安装 https://cygwin.com/install.html 在工具终端执行: rustup toolchain install stable-x86_64-pc-windows-gnu rustup default stable-x86_64-pc-windows-gnu 2、Hello World fn main() { println…...
