1.1.8 更新了啥,直接不能用了
Closed this issue · 15 comments
Error: Loading PostCSS Plugin failed: Cannot use import statement outside a module
已修复,麻烦更新至1.1.9版本使用
还是不行
Error: Loading PostCSS Plugin failed: req(...) is not a function
还是不行
Error: Loading PostCSS Plugin failed: req(...) is not a function
我的也报这个了
module.exports = {
plugins: {
'postcss-px-to-viewport-8-plugin': {
// 设计稿宽度
viewportWidth: 750,
exclude: [/node_modules/],
// 需要转换的单位,默认为"px"
unitToConvert: 'rpx',
},
},
};
@lkxian888 建议不要只在本地进行发版操作,及时提交一下,这样有问题我们也方便帮你排查...
我这边用你发git最新的编译后,还是一样报错,会不会是postcss版本影响?
"postcss": "^8.4.21",
"postcss-html": "^1.5.0",
"postcss-px-to-viewport-8-plugin": "^1.1.9",
@hlbj105 有demo给我测试下吗
@hlbj105 有demo给我测试下吗
@lkxian888 这个demo你试试 https://gitee.com/hlbj105/postcss-px-to-viewport-8-plugin-demo
@hlbj105 麻烦vite用户,在vite.config.ts 添加下面代码
import postcssPxToViewport8Plugin from 'postcss-px-to-viewport-8-plugin';
css: {
postcss: {
plugins: [
postcssPxToViewport8Plugin({
// 设计稿宽度
viewportWidth: 750,
exclude: [/node_modules/],
// 需要转换的单位,默认为"px"
unitToConvert: 'px',
}),
],
},
},
我的也是 vite 项目,放在 vite.config
里是没问题,但是还是希望把 postcss 相关的配置集中放到 postcss.config
里,而且 vite 文档也说明了,如果不配置 css.postcss
,就会去找项目内的 PostCSS 配置源,但是如果配置了,就不会再找,这点容易出问题,详见:vite#css-postcss 说明
我的也是 vite 项目,放在
vite.config
里是没问题,但是还是希望把 postcss 相关的配置集中放到postcss.config
里,而且 vite 文档也说明了,如果不配置css.postcss
,就会去找项目内的 PostCSS 配置源,但是如果配置了,就不会再找,这点容易出问题,详见:vite#css-postcss 说明
好的,晚点会修复哈,postcss.config 是采用 CommonJs 引入模块,我改了 Es6 模块导出,才出现这个问题