Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f64304b

Browse files
committed
init
0 parents  commit f64304b

File tree

12 files changed

+490
-0
lines changed

12 files changed

+490
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
.DS_Store?
3+
node_modules
4+
test/output/bundle.js

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
node_js:
3+
- 0.10

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Putain de Code !
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# cssnext-loader
2+
3+
> a webpack loader for cssnext
4+
5+
## install
6+
7+
```sh
8+
$ npm install cssnext-loader
9+
```
10+
11+
## api
12+
13+
### cssnext
14+
15+
in your `webpack.config.js`
16+
17+
```javascript
18+
module.exports = {
19+
entry: "path/to/entry",
20+
output: {
21+
path: "path/to/output/",
22+
filename: "bundle.js"
23+
},
24+
cssnext : {
25+
features : {
26+
import : {
27+
path : ["src/assets/stylesheets"]
28+
}
29+
}
30+
}
31+
}
32+
```
33+
34+
in your js file :
35+
36+
```javascript
37+
var css = require("style-loader!css-loader!../..!./file.css")
38+
```
39+
40+
you can also configure webpack so that it always parses CSS files like this :
41+
42+
```javascript
43+
module: {
44+
loaders: [
45+
{
46+
test: /\.css$/,
47+
loader: "style-loader!css-loader!cssnext-loader"
48+
}
49+
]
50+
}
51+
```
52+
53+
## [license](LICENSE)

index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var cssnext = require("cssnext")
2+
var assign = require("object-assign")
3+
4+
function cssnextLoader(contents){
5+
this.cacheable()
6+
var options = assign({}, this.options.cssnext)
7+
options.features = assign({}, this.options.cssnext ? this.options.cssnext.features : null)
8+
options.features.import = assign({}, options.features.import || null)
9+
options.features.import.onImport = function(files){
10+
files.forEach(function(file){
11+
this.addDependency(file)
12+
}, this)
13+
}.bind(this)
14+
try {
15+
return cssnext(contents, options)
16+
} catch(err) {
17+
this.emitError(err)
18+
}
19+
}
20+
21+
module.exports = cssnextLoader

package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "cssnext-loader",
3+
"version": "0.1.0",
4+
"description": "webpack loader for cssnext",
5+
"main": "index.js",
6+
"scripts": {
7+
"start" : "npm install && npm test",
8+
"test": "tape test/**.js"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/cssnext/cssnext-loader.git"
13+
},
14+
"keywords": [
15+
"webpack",
16+
"cssnext",
17+
"css",
18+
"loader"
19+
],
20+
"author": "bloodyowl",
21+
"license": "MIT",
22+
"bugs": {
23+
"url": "https://github.com/cssnext/cssnext-loader/issues"
24+
},
25+
"homepage": "https://github.com/cssnext/cssnext-loader",
26+
"dependencies": {
27+
"cssnext": "^0.6.0",
28+
"object-assign": "^2.0.0"
29+
},
30+
"devDependencies": {
31+
"css-loader": "^0.9.0",
32+
"style-loader": "^0.8.2",
33+
"tape": "^3.0.3",
34+
"webpack": "^1.4.13"
35+
}
36+
}

test/fixtures/file.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
body {
2+
color: var(--foo);
3+
}
4+
5+
@import "./foo.css";

test/fixtures/foo.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:root {
2+
--foo: red;
3+
}

test/fixtures/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var css = require("style-loader!css-loader!../..!./file.css")
2+
3+
module.exports = css

test/index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
var webpack = require("webpack")
2+
var path = require("path")
3+
var tape = require("tape")
4+
var fs = require("fs")
5+
6+
tape("cssnext-loader", function(test){
7+
webpack({
8+
entry: "./test/fixtures/index.js",
9+
output: {
10+
path: "./test/output/",
11+
filename: "bundle.js"
12+
},
13+
cssnext : {
14+
features : {
15+
import : {
16+
path : ["test/fixtures/"]
17+
}
18+
}
19+
}
20+
}, function(err, stat){
21+
var file = ""
22+
fs.createReadStream("test/output/bundle.js")
23+
.on("data", function(chunk){
24+
file += chunk
25+
})
26+
.on("end", function(){
27+
test.equal(/color\s*:\s*red/.test(file), true)
28+
test.end()
29+
})
30+
})
31+
})

0 commit comments

Comments
 (0)