responsive-css-loader
v2.0.0
Published
transer responsive css unit to rem
Downloads
2
Readme
安装
npm install responsive-css-loader --save
使用
module.exports = {
entry: {
main: path.resolve(__dirname, './app/index.js'),
},
output: {
path: path.resolve(__dirname, './output'),
},
module: {
rules: [
{
test: /\.css$/,
use: [
'css-loader',
{
loader: 'responsive-css-loader' // 将css中的 'rem(16)' 转换为 '1rem'
}
]
}
],
}
}
options
use: [
'css-loader',
{
loader: 'responsive-css-loader',
options: {
transfer: (size) => {
return size;
},
exact: true
}
}
]
transfer
// 自定义转换规则
是否精确转换
// 精确转换会将css先解析成抽象语法树再将其中的属性值进行转换