- change px to rem
npm i okwzh-css-loader --save-dev
In webpack.config.js
...
module: {
rules: [{
test: /\.css$/,
include: path.resolve(__dirname, 'src'),
use: extractCSS.extract({
use: [{
loader: 'css-loader',
},
{
loader: 'okwzh-css-loader',
options: {
pxtorem: { rootValue: 50 }
}
}]
})
}
...
]
}
...
set options like this:
{
loader: 'okwzh-css-loader',
options: {
pxtorem: { rootValue: 50 } // base font-size is 50px
}
}