57 npm run build 和 npm run serve 的差异

前言

npm run serve 和 npm run build 的差异

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

经过了那些流程 ?

 

 

vue-cli 的 vue-plugin 的加载

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

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

2953f72fc17b4783917899015b7c70b2.png

 

 

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

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

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

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

 

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

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

 

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

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

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

e80983b03f1d4071892d11269c277aa2.png

 

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

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

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

eb91dc089eac4b5e866efacede361396.png

 

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

f09066def1244741b95e10362dc4dc06.png

 

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

c040e88365b349fdb05324f51a6aa5b3.png

 

 

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

如下是 npm run serve 的 plugin 列表

811f96a4c17848e9898d564821026635.png

 

如下是 npm run build 的 plugin 列表

0dcf848f7cd9471792677216bde1c180.png

 

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

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

525e0223d8fa4d5ca8e642e7416a9fc5.png

 

 

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

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

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

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

244a002d22bf44a0a138966d2cbbcb40.png

 

 

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

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

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

26bb87c515714b058d93ad7831da72a0.png

 

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

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

2595b7b9e0834dea82172b4f4a65e5b1.png

 

 

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

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

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

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

e57191fae9204ee09101505a58726a14.png

 

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

c1eb1459e6be4692ba7196f4cdf4ca83.png

 

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

77bb18568fa447858495f6e9b6aff05d.png

 

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

e810cfa645ea4ccb9ee757d64f032273.png

 

最终写出的文件信息如下

81057d8452c947c6859ca20dc2c1c1fc.png

 

writeToDisk 参数的文档

d0f3fb68fd8c46ffbb3872d01c6afcd1.png

 

outputFileSystem 参数的文档

8e045860028147bc92b724efe321dc16.png

 

 

完 

 

 

 

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

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Python云计算技术库之libcloud使用详解

概要 随着云计算技术的发展,越来越多的应用和服务迁移到了云端。然而,不同云服务商的API和接口千差万别,给开发者带来了不小的挑战。Python的libcloud库应运而生,它提供了一个统一的接口,让开发者可以轻松地管理不同云服务商的资源。本文将深入探讨libcloud库的特性、安装…

keycloak - 鉴权VUE

目录 一、前言 1、背景 2、实验版本 二、开始干活 1、keycloak配置 a、创建领域(realms) b、创建客户端 c、创建用户、角色 2、vue代码 a、依赖 b、main.js 三、未解决的问题 目录 一、前言 1、背景 2、实验版本 二、开始干活 1、keycloak配置 a、创建领域(r…

51单片机入门:认识开发板

认识开发板 板载资源: 数码管模块 说明: 2个四位一体共阴数码管 详细: 2个四位一体:两个独立的四位数码管,每个四位数码管都是“一体”的设计,也就是说,每个数码管内部集成了四个独立的七段LE…

【学习】成为优秀的软件测试工程师需要学哪些知识

成为软件测试工程师,需要学习的内容非常的多,但是无非是这几大类,今天就和小编一起来看看这些知识,你是否都已经掌握。 01、测试环境的搭建 本部分主要是学习从操作系统开始,有关的计算机基础知识、软件和硬件知识、…

golang设计模式图解——模板方法模式

设计模式 GoF提出的设计模式有23个,包括: (1)创建型(Creational)模式:如何创建对象; (2)结构型(Structural )模式:如何实现类或对象的组合; (3&a…

LeNet卷积神经网络

文章目录 简介conv2d网络层的结构 简介 它是最早发布的卷积神经网络之一 conv2d 这个卷积成的参数先进行介绍一下: self.conv1 nn.Conv2d(in_channels3, out_channels10, kernel_size3, stride1, padding1)先看一下in_channels 输入的通道数,out_cha…

初识MySQL(中篇)

使用语言 MySQL 使用工具 Navicat Premium 16 代码能力快速提升小方法,看完代码自己敲一遍,十分有用 目录 1.SQL语言 1.1 SQL语言组成部分 2.MySQL数据类型 2.1 数值类型 2.2 字符串类型 2.3 日期类型 3.创建数据表 3.1 创建数据表方法1 …

scala实现通过Spark统计人均登录次数最终写入MySQL

谨以此博客作为记录 小编这里用的版本是&#xff1a; <hadoop.version>2.7.7</hadoop.version> <spark.version>2.4.5</spark.version> <scala.version>2.12.10</scala.version> 如果没用到Hadoop可以忽略 步骤 准备数据&#xff0c;知道…

Python网络爬虫(四):b站评论

首先来看一下采集的数据格式: 本文不对数据采集的过程做探讨,直接上代码。首先要在程序入口处bvids列表内替换成自己想要采集的视频bvid号,然后将self.cookies替换成自己的(需要字典格式),代码可以同时爬取多个视频的评论,且爬取的评论较为完整,亲测有效: im…

SRS 实时视频服务器搭建及使用

一、SRS 介绍 SRS是一个开源的&#xff08;MIT协议&#xff09;简单高效的实时视频服务器&#xff0c;支持RTMP、WebRTC、HLS、HTTP-FLV、SRT、MPEG-DASH和GB28181等协议。 SRS媒体服务器和FFmpeg、OBS、VLC、 WebRTC等客户端配合使用&#xff0c;提供流的接收和分发的能力&am…

【QT+QGIS跨平台编译】056:【PDAL+Qt跨平台编译】(pdalcpp错误处理)

点击查看专栏目录 文章目录 一、报错信息:二、原因分析三、解决思路四、原版FileUtils.cpp五、修改后的FileUtils.cpp一、报错信息: ① exists is unavaiable: introduced in macOS 10.15 ② create_directory is unavaiable: introduced in macOS 10.15 ③ create_director…

VSCode美化

今天有空收拾了一下VSCode&#xff0c;页面如下&#xff0c;个人觉得还是挺好看的~~ 1. 主题 Noctis 色彩较多&#xff0c;有种繁杂美。 我使用的是浅色主题的一款Noctis Hibernus 2. 字体 Maple Mono 官网&#xff1a;Maple-Font 我只安装了下图两个字体&#xff0c;使…

基于Python近红外光谱分析与机器学、深度学习方法融合技术应用

郁磊副教授&#xff0c;主要从事MATLAB 编程、机器学习与数据挖掘、数据可视化和软件开发、人工智能近红外光谱分析、生物医学系统建模与仿真&#xff0c;具有丰富的实战应用经验&#xff0c;主编《MATLAB智能算法30个案例分析》、《MATLAB神经网络43个案例分析》相关著作。已发…

数据结构和算法:十大排序

排序算法 排序算法用于对一组数据按照特定顺序进行排列。排序算法有着广泛的应用&#xff0c;因为有序数据通常能够被更高效地查找、分析和处理。 排序算法中的数据类型可以是整数、浮点数、字符或字符串等。排序的判断规则可根据需求设定&#xff0c;如数字大小、字符 ASCII…

什么是Redis共享Session?

如图所示&#xff0c;一个分布式部署的Web服务器将用户的Session信息&#xff08;例如用户登录信息&#xff09;&#xff0c;保存在各自服务器内部。这样会造成一个问题&#xff0c;在分布式部署多个Web服务器时&#xff0c;我们通常会采用负载均衡算法&#xff0c;将多个用户的…

语义分割——自动驾驶鱼眼数据集

一、重要性及意义 环境感知&#xff1a;语义分割技术能够精确识别道路、车辆、行人、障碍物、交通标志和信号等各种交通场景元素。这为自动驾驶系统提供了丰富的环境信息&#xff0c;有助于车辆准确理解周围环境的结构和动态变化。决策规划&#xff1a;基于语义分割的结果&…

GIS水文分析计算流向学习

1 初步操作 流向&#xff0c;即水文表面水的流向&#xff1b; 水文分析的很多功能需要基于流向栅格&#xff1b; 在 SuperMap 中&#xff0c;对中心栅格的8个邻域栅格进行编码&#xff1b; 每一个中心栅格的水流方向都由这八个值中的某一个值来确定&#xff1b; 我还没弄懂水…

C语言中的结构体:揭秘数据的魔法盒

前言 在C语言的广阔天地中&#xff0c;结构体无疑是一颗璀璨的明珠。它就像是一个魔法盒&#xff0c;能够容纳各种不同类型的数据&#xff0c;并按我们的意愿进行组合和排列。那么&#xff0c;这个魔法盒究竟有何神奇之处呢&#xff1f;让我们一探究竟。 一、结构体的诞生&…

备战蓝桥杯---多路归并与归并排序刷题

话不多说&#xff0c;直接看题 1. 我们考虑一行一行合并&#xff0c;一共m次&#xff0c;我们合并两个并取前n小&#xff0c;那么我们怎么取&#xff1f; 我们采用分组的思想&#xff1a; 我们选第一列的min,然后把后面那个再纳入考虑&#xff0c;用优先队列实现即可。 下面…

Flutter学习笔记-Widget

1.Widget概念 字面意思就是 装饰物/小部件,在Flutter中几乎所有的对象都是一个 widget。Widget 的功能是“描述一个UI元素的配置信息”(所谓的配置信息就是 Widget 接收的参数,比如对于 Text 来讲,文本的内容、对齐方式、文本样式都是它的配置信息)。与原生相比,原生开发…