vue打包编译【自动删除node_modules下的.cache缓存文件夹】
vue项目不断打包编译后,在node_modules目录下的.cache文件夹里的文件就越来越多,手动删除数量巨大,时间太长,下面是自动删除.cache这个文件夹的方法
1.先安装依赖包rimraf:
npm install rimraf -g --save-dev
2. 在 package.json 文件的 scripts 部分添加一个脚本命令:
"scripts": {
"clean": "rimraf node_modules/.cache"
}
3. 运行脚本命令,清除.cache文件夹:
npm run clean
4. 在dev、build命令里都加入clean命令:
"scripts": {
"dev": "npm run clean && vue-cli-service serve",
"build": "npm run clean && vue-cli-service build"
}
在起项目或者打包之前,这个目录就会被自动清除 !