Last active
December 29, 2016 10:48
-
-
Save ronen-e/17db4566bb0d14cf331b53be92578ae2 to your computer and use it in GitHub Desktop.
class prefixer using postcss-loader for webpack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import classPrfx from 'postcss-class-prefix'; | |
import precss from 'precss'; // for scss support | |
module: { | |
loaders: [ | |
{ | |
test: /\.scss$/, | |
loaders: [ | |
'style', | |
'css', | |
'postcss' | |
'sass' | |
] | |
}, | |
{ | |
test: /\.css$/, | |
loader: 'style-loader!css-loader?!postcss-loader' | |
// loader: 'css?camelCase&modules&importLoaders=1&localIdentName=[name]___[local]___[hash:base64:5]', // modules support | |
}, | |
] | |
}, | |
postcss() { | |
return [ precss, classPrfx('my-prefix-', { ignore: [/some-class-/] }) ]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var postcss = require('postcss'); | |
var classPrfx = require('postcss-class-prefix'); | |
var css = fs.readFileSync('/index.css', 'utf8').toString(); | |
var out = postcss() | |
.use(classPrfx('my-prefix-')) | |
.process(css); | |
fs.writeFileSync('/prefixed.css', out); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment