PostCSS plugin to add px unit for number of length.
const postcss = require('postcss');
const pxplugin = require('postcss-auto-add-px');
const fs = require('fs');
try{
fs.readFile('./demo/index.less', (err, css) => {
postcss([pxplugin()])
.process(css.toString(), { from: './demo/index.less', to: './demo/dist/index.less' })
.then(result => {
fs.writeFile('./demo/dist/index.less', result.css, () => true)
})
})
} catch (err) {
console.log(err)
}
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
vueLoaderConfig,
postcss: [require('postcss-auto-add-px')(), require('autoprefixer')()]
}
}
postcss([ require('postcss-auto-add-px') ])
See PostCSS docs for examples for your environment.