[產生原因] : autoprefixer自動移除老式過時的代碼
[關於autoprefixer] : https://www.npmjs.com/package/autoprefixer
[解決]
方法一:添加註釋關閉autoprefixer,但是若果有清除註釋的插件,請將該插件設爲false,否則不生效
/* autoprefixer: off */
-webkit-box-orient: vertical;
/* autoprefixer: on */
方法二:將autoprefixer設置爲false或者只是將移除功能關閉
autoprefixer: {remove:false}
需要注意的是cssnano裏會有對autoprefixer的配置,而在使用webpack進行css壓縮時有使用到optimize-css-assets-webpack-plugin插件,而這個插件實際上就是依靠cssnano來實現其功能,所以我們需要修改插件的配置(如下)
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
new OptimizeCSSPlugin({
cssProcessorOptions: {
safe: true, map: { inline: false },
autoprefixer: { remove: false } //添加對autoprefixer的配置
}
})