配置postcss-pxtorem报:options has an unknown property 'plugins'
闲聊:
小颖最近在坐大屏相关的项目,要写适配,之前用的:postcss-px2rem、px2rem-loader,和朋友闲聊呢他说他们也在写大屏,不过他们用的 postcss-pxtorem,在写另外一个项目时,小颖就想着试试 postcss-pxtorem ,结果配置到 vue.config.js 后就报错················如下图所示:

报错分析及解决方案:
vue项目安装使用postcss-pxtorem,在vue.config.js中进行配置,需要注意vue-cli-service的版本。如若vue-cli-service的版本为4,可直接在vue.config.js中进行配置。代码如下:
const { defineConfig } = require('@vue/cli-service')
const name = process.env.VUE_APP_TITLE || 'xxxxx' // 网页标题
const pxtorem = require('postcss-pxtorem');
module.exports = defineConfig({
transpileDependencies: true,
configureWebpack: { name: name, },
css: {
loaderOptions: {
sass: {
sassOptions: { outputStyle: "expanded" }
},
postcss: {
plugins: [
pxtorem({
rootValue: 37.5,
propList: ['*'],
}),
]
}
}
}
})
如若vue-cli-service的版本为5,则按以上配置无效,将 vue.config.js 中的 postcss 配置修改成下面的配置
const { defineConfig } = require('@vue/cli-service')
const name = process.env.VUE_APP_TITLE || 'xxxx' // 网页标题
const pxtorem = require('postcss-pxtorem');
module.exports = defineConfig({
transpileDependencies: true,
configureWebpack: { name: name, },
css: {
loaderOptions: {
sass: {
sassOptions: { outputStyle: "expanded" }
},
postcss: {
postcssOptions: {
plugins: [
pxtorem({
rootValue: 37.5,
propList: ['*'],
}),
],
}
}
}
}
})
相关内容:
在vue项目中如何解决适配问题:
方案一:使用 postcss-pxtorem 插件
1.下载插件
npm i postcss-pxtorem@5.1.1 -D
2.在 utils 文件 中创建 rem.js
const baseSize = 16
function setRem() {
const scale = document.documentElement.clientWidth / 1920
let fontSize = (baseSize * Math.min(scale, 2)) > 12 ? (baseSize * Math.min(scale, 2)) : 12
document.documentElement.style.fontSize = fontSize + 'px'
}
setRem()
window.onresize = function () {
setRem()
}
3.在 main.js 中引入 rem.js
import './utils/rem'//屏幕适配
方案二:使用 postcss-px2rem、px2rem-loader 插件
希望对大家有所帮助呦·································
配置postcss-pxtorem报:options has an unknown property 'plugins'的更多相关文章
- options has an unknown property 'modifyVars'. These properties are valid: 处理方法
webpack 编译时提示 ValidationError: Invalid options object. Less Loader has been initialized using an opt ...
- Nginx配置SSL报错 nginx: [emerg] unknown directive "ssl"
Nginx配置SSL报错 nginx: [emerg] unknown directive "ssl" 出现如图所示错误,处理办法如下 去nginx解压目录下执行 ./co ...
- 疑难杂症:org.hibernate.MappingException: Unknown entity,annotation配置Entity类报错
引言: 夜声人静,外面下着稀里哗啦的雨,周末的晚上,还在键盘上舞动手指. 此刻很感激一个人一篇随笔,感谢xiaochao以及他的<org.hibernate.MappingException: ...
- nuxt/eapress 安装报错Module build failed: ValidationError: PostCSS Loader Invalid OptionsModule build failed: ValidationError: PostCSS Loader Invalid Options options['useConfigFile'] is an invalid additi
错误信息: Module build failed: ValidationError: PostCSS Loader Invalid Options options['useConfigFile'] ...
- springboot 配置jpa启动报Error processing condition on org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration.pageableCustomizer
springboot +gradle 配置jpa启动报Error processing condition on org.springframework.boot.autoconfigure.data ...
- appium报错:An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: read ECONNRESET
Appium Desktop版本:1.9.0 xcode版本:9.4.1 测试机:iPhone7 11.3系统 问题描述:在xcode上的produc的text运行是可以将WebDriverAgen ...
- 配置MySQL主从复制报错Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work
配置MySQL主从复制报错 ``` Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave ha ...
- 解决jira配置gmail邮箱报错
具体报错: AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at 535 ...
- Vue项目 invalid host header 问题 配置 disableHostCheck:true报错
项目场景: 解决 Vue 项目 invalid host header 问题disableHostCheck:true报错 问题描述 使用内网穿透时出现 invalid host header 找了好 ...
- - configuration.module has an unknown property 'loader' 问题解决
错误提示: Invalid configuration object. Webpack has been initialised using a configuration object that d ...
随机推荐
- 基于C#的窗体阴影效果方案 - 开源研究系列文章
最近在研究C#的Winform窗体的效果,上次介绍了窗体动画效果的博文( 基于C#的无边框窗体动画效果的完美解决方案 - 开源研究系列文章 ),这次将窗体阴影效果的方案进行一个介绍. 找了一下度娘,具 ...
- 【转自知乎】NLP算法面试必备!史上最全!PTMs:NLP预训练模型的全面总结
NLP算法面试必备!史上最全!PTMs:NLP预训练模型的全面总结 预训练模型(Pre-trained Models,PTMs)的出现将NLP带入了一个全新时代.2020年3月18日,邱锡鹏老师发表了 ...
- 在centos7.X下安装Java
发布于 2 分钟前 2 次阅读 1.创建JDK目录 mkdir /opt/jdk 2.通过finalshell或xftp将jdk上传到/opt/jdk目录中 3.cd /opt/jdk 4.解压jd ...
- 当小白遇到FullGC
起初没有人在意这场GC,直到它影响到了每一天! 前言 本文记录了一次排查FullGC导致的TP99过高过程,介绍了一些排查时思路,线索以及工具的使用,希望能够帮助一些新手在排查问题没有很好的思路时,提 ...
- 【测试】自定义配置 RocksDB 进行 YCSB 测试
目录 简介 编译 RocksDB 编译 YCSB 修复报错 自定义配置 RocksDB 进行 YCSB 测试 参考资料 本文主要记录在利用 YCSB 使用配置文件测试 RocksDB 的过程中遇到的一 ...
- Pytest 框架执行用例流程浅谈
背景: 根据以下简单的代码示例,我们将从源码的角度分析其中的关键加载执行步骤,对pytest整体流程架构有个初步学习. 代码示例: import pytest def test_add(): asse ...
- 千万级数据的表,我把慢sql优化后性能提升30倍!
分享技术,用心生活 背景:系统中有一个统计页面加载特别慢,前端设置的40s超时时间都加载不出来数据,因为是个统计页面,基本上一猜就知道是mysql的语句有问题,遗留了很久没有解决,正好趁不忙的时候,下 ...
- [Qt开发探幽(二)]浅谈关于元对象,宏和Q_ENUM
目录 [Qt开发探幽(二)]浅谈关于元对象,宏和Q_ENUM 前言 一.元对象 但是 二.关于Q_OBJECT等宏属性 1.元对象系统 2.信号与槽 3.属性系统 三.关于Q_ENUMS 1.将其注册 ...
- API接口的应用场景
API数据接口的应用非常广泛,不同的行业和领域都可以使用API数据接口来获取所需的数据,从而实现数据分析.数据挖掘.数据统计等操作.以下是一些常见的API数据接口应用场景: 电商平台:例如淘宝.京东等 ...
- Jenkins 命令执行 -- jetty 敏感信息泄露 --(CVE-2021-2816)&&(CVE-2017-1000353)&&(CVE-2018-1000861)
Jenkins 命令执行 -- jetty 敏感信息泄露 --(CVE-2021-2816)&&(CVE-2017-1000353)&&(CVE-2018-100086 ...