我正在尝试将customMedia option添加到文件位置为importFrom
的postcss-cssnext features配置中,但这不起作用,并且我没有任何错误项目构建,仅当我尝试使用媒体时才最终Missing @custom-media definition for '--small-viewport'. The entire rule has been removed from the output.
。我该如何调试?
module.exports = {
plugins: [
require('postcss-import')(),
require('postcss-nested')(),
require('postcss-simple-vars')({
variables: {
...require('./src/ui/variables')
}
}),
require('postcss-cssnext')({
features: {
customProperties: false,
browsers: ['> 0.5%, last 2 versions, Firefox ESR, not dead'],
customMedia: {
importFrom: require('path').join(__dirname, './src/ui/custom-media.css')
}
},
}),
require('cssnano')({
autoprefixer: false,
zindex: false,
reduceIdents: false,
discardComments: { removeAll: true },
discardUnused: { fontFace: false },
colormin: false,
}),
]
};
答案 0 :(得分:0)
好吧,按照postcss-custom-media CHANGELOG,importFrom仅在7.0.0中添加,而我的cssnext使用6.0.0。随着CSSNext的弃用,我将切换到postcss-preset-env
答案 1 :(得分:0)
您知道如何在postcss-preset-env中使用自定义媒体,仅当您在组件中创建自定义媒体时,它们才对我有用,并且如果我想从index.css或vars.css中获取自定义媒体,请参考它它们不起作用,带有变量,一切都很好