如何移除Angular 11中的autoprefixer前缀提示警告?
移除Angular 11中Autoprefixer的"无需前缀"警告
方法一:修改angular.json配置
- 打开项目根目录的
angular.json文件 - 定位到
projects-> 你的项目名称 ->architect->build->options节点 - 添加或修改
postcss配置:- 若要直接禁用Autoprefixer插件(无需前缀支持时使用):
"postcss": { "plugins": { "autoprefixer": false } } - 若仅需关闭警告(仍保留插件功能):
"postcss": { "plugins": { "autoprefixer": { "warnRemoval": false } } }
- 若要直接禁用Autoprefixer插件(无需前缀支持时使用):
方法二:配置postcss.config.js文件
- 在项目根目录创建或编辑
postcss.config.js文件 - 根据需求写入配置:
- 禁用Autoprefixer插件:
module.exports = { plugins: { // 不声明autoprefixer即可移除插件 } }; - 仅关闭警告:
module.exports = { plugins: { autoprefixer: { warnRemoval: false } } };
- 禁用Autoprefixer插件:
注意事项
- 如果你仍需要兼容旧版本浏览器,建议选择关闭警告而非禁用Autoprefixer,避免丢失前缀支持
- 修改配置后重启开发服务器,警告即可消失
内容的提问来源于stack exchange,提问作者Shri
相关产品推荐
相关产品推荐

