Skip to content

Commit bc2408e

Browse files
committed
in the beginning
0 parents  commit bc2408e

7 files changed

Lines changed: 182 additions & 0 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
npm-debug.log*

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# sheetify-postcss
2+
3+
postcss transform for sheetify, use all the plugins!
4+
5+
```shell
6+
npm install --save sheetify-postcss
7+
```
8+
9+
## usage
10+
11+
### programmatic
12+
13+
```
14+
const sheetify = require('sheetify/stream')
15+
const path = require('path')
16+
17+
const opts = {
18+
use: [
19+
[
20+
'sheetify-postcss', {
21+
plugins: [
22+
require('postcss-color-function')
23+
]
24+
}
25+
]
26+
],
27+
basedir: __dirname
28+
}
29+
30+
browserify('./entry')
31+
.transform('sheetify', opts)
32+
.bundle()
33+
.pipe(process.stdout)
34+
```
35+
36+
### with `package.json`
37+
38+
add to your `package.json` `browserify.transform` field:
39+
40+
```json
41+
{
42+
"browserify": {
43+
"transform": [
44+
[
45+
"sheetify/transform",
46+
{
47+
"use": [
48+
[
49+
"sheetify-postcss",
50+
{
51+
"plugins": [
52+
"postcss-color-function"
53+
]
54+
}
55+
]
56+
]
57+
}
58+
]
59+
]
60+
}
61+
}
62+
```
63+
64+
## license
65+
66+
The Apache License
67+
68+
Copyright © 2016 Michael Williams
69+
70+
Licensed under the Apache License, Version 2.0 (the "License");
71+
you may not use this file except in compliance with the License.
72+
You may obtain a copy of the License at
73+
74+
http://www.apache.org/licenses/LICENSE-2.0
75+
76+
Unless required by applicable law or agreed to in writing, software
77+
distributed under the License is distributed on an "AS IS" BASIS,
78+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
79+
See the License for the specific language governing permissions and
80+
limitations under the License.

example/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const css = require('sheetify')
2+
3+
const prefix = css`
4+
:host {
5+
width: 100%;
6+
background: color(red a(90%))
7+
}
8+
`

example/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"browserify": {
3+
"transform": [
4+
[
5+
"sheetify/transform",
6+
{
7+
"use": [
8+
[
9+
".",
10+
{
11+
"plugins": [
12+
"postcss-color-function"
13+
]
14+
}
15+
]
16+
]
17+
}
18+
]
19+
]
20+
}
21+
}

index.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const defined = require('defined')
2+
const postcss = require('postcss')
3+
const extend = require('xtend')
4+
const resolve = require('resolve')
5+
6+
module.exports = transform
7+
8+
function transform (filename, source, options, done) {
9+
options = defined(options, {})
10+
11+
const basedir = options.basedir
12+
13+
const plugins = defined(options.plugins, [])
14+
.map(plugin => resolve.sync(plugin, { basedir }))
15+
.map(require)
16+
17+
postcss(plugins)
18+
.process(source, extend({
19+
sourcemap: true,
20+
from: filename,
21+
messages: {
22+
browser: true,
23+
console: false
24+
}
25+
}, options))
26+
.then(function (result) {
27+
done(null, result.css)
28+
})
29+
.catch(function (err) {
30+
done(err)
31+
})
32+
}

package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "sheetify-postcss",
3+
"version": "0.0.0",
4+
"description": "postcss transform for sheetify, use all the plugins!",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "pull-test test/*.js",
8+
"example": "browserify example"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/ahdinosaur/sheetify-postcss.git"
13+
},
14+
"keywords": [],
15+
"author": "Mikey <michael.williams@enspiral.com> (http://dinosaur.is)",
16+
"license": "Apache-2.0",
17+
"bugs": {
18+
"url": "https://github.com/ahdinosaur/sheetify-postcss/issues"
19+
},
20+
"homepage": "https://github.com/ahdinosaur/sheetify-postcss#readme",
21+
"devDependencies": {
22+
"browserify": "^13.1.0",
23+
"postcss-color-function": "^2.0.1",
24+
"pull-test": "^1.2.3",
25+
"sheetify": "^5.1.0",
26+
"tape": "^4.5.1"
27+
},
28+
"dependencies": {
29+
"postcss": "^5.1.2"
30+
}
31+
}

test/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var sheetifyPostcss
2+
3+
module.exports = {
4+
'sheetify-postcss': function (assert) {
5+
sheetifyPostcss = require('../')
6+
assert.ok(sheetifyPostcss, 'module is require-able')
7+
}
8+
}

0 commit comments

Comments
 (0)