File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /node_modules /
Original file line number Diff line number Diff line change 1+ .gitignore
2+ /test /
3+ /example /
Original file line number Diff line number Diff line change 11# browserify-postcss
22transform contents using postcss
3+
4+ ## Usage
5+
6+ example/var.js:
7+
8+ ``` javascript
9+ var plugin = require (" browserify-postcss" )
10+
11+ var tr = plugin (" fake.css" , {
12+ plugin: " postcss-simple-vars" ,
13+ resolve: {
14+ basedir: __dirname
15+ }
16+ })
17+ tr .end (" $color: red; .fake { color: $color; }" )
18+ tr .pipe (process .stdout )
19+
20+ ```
21+
22+ output:
23+
24+ ```
25+ ⌘ node example/vars.js
26+ .fake { color: red; }
27+ ```
28+
29+ ### tr = plugin(file, opts)
30+
31+ ### Options
32+
33+ #### plugin
34+
35+ Type: ` String|Array `
36+ Default: ` null `
37+
38+ postcss plugins used to transform the content
39+
40+ #### options
41+
42+ Type: ` Object `
43+ Default: ` null `
44+
45+ options for postcss plugins specified by ` opts.plugin `
46+
47+ #### resolve
48+
49+ Type: ` Object|Function `
50+ Default: ` null `
51+
52+ If ` Object ` , will be passed to [ resolve.sync] ( https://github.com/substack/node-resolve#resolvesyncid-opts ) to resolve the plugins.
53+ If ` Function ` , will be used instead of [ resolve.sync] ( https://github.com/substack/node-resolve#resolvesyncid-opts )
Original file line number Diff line number Diff line change 1+ var plugin = require ( ".." )
2+
3+ var tr = plugin ( "fake.css" , {
4+ plugin : "postcss-simple-vars" ,
5+ resolve : {
6+ basedir : __dirname
7+ }
8+ } )
9+ tr . end ( "$color: red; .fake { color: $color; }" )
10+ tr . pipe ( process . stdout )
Original file line number Diff line number Diff line change 1+ var Processor = require ( "postcss-processor" )
2+ var sink = require ( "sink-transform" )
3+
4+ var processor
5+ module . exports = function ( file , opts ) {
6+ opts = opts || { }
7+ if ( ! processor ) {
8+ processor = Processor ( opts . plugin , opts . options , opts . resolve )
9+ }
10+ return sink . str ( function ( body , done ) {
11+ var self = this
12+ processor . process ( body , { from : file } )
13+ . then ( function ( result ) {
14+ self . push ( result . css )
15+ done ( )
16+ } )
17+ } )
18+ }
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " browserify-postcss" ,
3+ "version" : " 0.0.1" ,
4+ "description" : " transform contents using postcss" ,
5+ "main" : " index.js" ,
6+ "scripts" : {
7+ "test" : " tape test/*.js"
8+ },
9+ "repository" : {
10+ "type" : " git" ,
11+ "url" : " git+https://github.com/zoubin/browserify-postcss.git"
12+ },
13+ "keywords" : [
14+ " browserify" ,
15+ " postcss"
16+ ],
17+ "author" : " zoubin" ,
18+ "license" : " MIT" ,
19+ "bugs" : {
20+ "url" : " https://github.com/zoubin/browserify-postcss/issues"
21+ },
22+ "homepage" : " https://github.com/zoubin/browserify-postcss#readme" ,
23+ "dependencies" : {
24+ "postcss-processor" : " ^0.1.0" ,
25+ "sink-transform" : " ^0.1.2"
26+ },
27+ "devDependencies" : {
28+ "postcss-simple-vars" : " ^0.3.0" ,
29+ "tape" : " ^4.0.0"
30+ }
31+ }
Original file line number Diff line number Diff line change 1+ var processor = require ( ".." )
2+ var sink = require ( "sink-transform" )
3+ var test = require ( "tape" )
4+
5+ test ( 'transform' , function ( t ) {
6+ t . plan ( 1 )
7+ var tr = processor ( "fake.css" , {
8+ plugin : "postcss-simple-vars" ,
9+ resolve : {
10+ basedir : __dirname
11+ }
12+ } )
13+ tr . end ( "$color: red; .fake { color: $color; }" )
14+ tr . pipe ( sink . str ( function ( body ) {
15+ t . equal ( body , ".fake { color: red; }" )
16+ } ) )
17+ } )
18+
You can’t perform that action at this time.
0 commit comments