- 本地运行报错
ERROR Failed to compile with 1 errors 2:34:34 PM
error in css/app.fc6d2467.css
Cannot use [chunkhash] or [contenthash] for chunk in 'js/[name].[contenthash:8].js' (use [hash] instead)
问题原因:未配置 env.fat.local 文件,其中 **NODE_ENV=development**
服务运行时会根据环境变量中 NODE_ENV 的 配置决定是否读取加过hash的内容;
未配置 NODE_ENV=development 时,vue.config.js 中的配置项 filenameHashing 默认为true, 服务会读取 加过 contenthsh:8 过后的文件;
而配置了 NODE_ENV=development 时,服务则会读取未加 hash 的文件;
NODE_ENV=development 时,编译时默认不会加 contenthsh:8;
本文介绍了解决Vue项目本地运行时遇到的CSS文件hash冲突错误的方法。问题出现在未正确配置.env.fat.local文件中的NODE_ENV环境变量,导致开发环境中读取了错误的文件版本。通过设置NODE_ENV=development来确保开发环境读取未加hash的文件。

2661

被折叠的 条评论
为什么被折叠?



