vue.js - 在使用 VueJS 热重载期间,Webpack 在“95% 发出 CopyPlugin”时很慢
问题描述
在热重载期间,Webpack 会卡住95% emitting CopyPlugin
几秒钟。
我的公共文件夹中有很多文件,主要是图像(大约 1GB),它们必须显示在我的 VueJS 应用程序上。如果我删除它们,我不再有问题。
这是我的package.json
依赖项:
{
...
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.4",
"register-service-worker": "^1.7.1",
"vue": "^2.6.11",
"vue-router": "^3.1.6"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.3.0",
"@vue/cli-plugin-eslint": "~4.3.0",
"@vue/cli-plugin-pwa": "~4.3.0",
"@vue/cli-plugin-router": "~4.3.0",
"@vue/cli-service": "~4.3.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"sass": "^1.26.3",
"sass-loader": "^8.0.2",
"vue-template-compiler": "^2.6.11"
}
}
这是我的 vue.config.js 文件:
const path = require("path");
function resolveSrc(_path) {
return path.join(__dirname, _path);
}
// vue.config.js
module.exports = {
lintOnSave: true,
configureWebpack: {
// Set up all the aliases we use in our app.
resolve: {
alias: {
assets: resolveSrc("src/assets"),
},
},
output: {
chunkFilename: "[id].[hash].js",
crossOriginLoading: "anonymous",
filename: "[name].[hash].js",
path: path.resolve(__dirname, "dist"),
}
},
css: {
// Enable CSS source maps.
sourceMap: process.env.NODE_ENV !== "production",
},
};
我本来希望 Webpack 缓存我的公共文件,而不是在每次重新加载时再次复制它们。也许有办法配置它,但是我对Webpack和vue-cli没有很好的了解。如果有人有解决方案来缓存/加速我的应用程序的热重载,那就太好了,非常感谢!
解决方案
推荐阅读
- sql-server - SQL 命令模式 - 无法运行命令
- mysql - 消息:类型注册表 TypeRegistry
- java - 从 Heroku 上托管的 java 应用程序运行 Heroku CLI 命令
- python - -xxxx 在日期时间格式中是什么意思?以及如何比较?
- c# - UI 元素调度程序 - 使用哪个?
- java - 在 Java 中使用 iText 对 PDF 文件进行不可移除的水印
- react-native - 带有过滤器的 POST 请求正文在本机反应中
- r - 如何汇总除我指定的列之外的所有列?
- typescript - 在 Typscript 中,如何将其设置为 ECMAScript 5?
- r - R中的TwoSum函数