0.0.2 • Published 6 years ago

postcss-auto-add-px v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

PostCSS Auto Add Px Build Status

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)
}

Webpack config

{
  test: /\.vue$/,
  loader: 'vue-loader',
  options: {
    vueLoaderConfig,
    postcss: [require('postcss-auto-add-px')(), require('autoprefixer')()]
  }
}

Usage

postcss([ require('postcss-auto-add-px') ])

See PostCSS docs for examples for your environment.