├── .gitignore
├── .npmignore
├── index.js
├── package.json
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_*
2 | *.log
3 | logs
4 | **/*.backup.*
5 | **/*.back.*
6 |
7 | node_modules
8 | bower_componets
9 |
10 | *.sublime*
11 |
12 | psd
13 | thumb
14 | sketch
15 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .DS_*
2 | *.log
3 | logs
4 | **/*.backup.*
5 | **/*.back.*
6 |
7 | node_modules
8 | bower_componets
9 |
10 | *.sublime*
11 |
12 | psd
13 | thumb
14 | sketch
15 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | const parseCss = require('gulp-react-native-stylesheet-css/lib/parseCss')
2 |
3 | module.exports = source => {
4 | const style = parseCss(source.replace(/\r?\n|\r/g, ""))
5 | return `const React = require('react-native');\nmodule.exports = React.StyleSheet.create(${style});`
6 | }
7 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-css-loader",
3 | "version": "1.0.2",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git+https://github.com/thewei/react-native-css-loader.git"
12 | },
13 | "keywords": [
14 | "react",
15 | "react-native",
16 | "css",
17 | "webpack",
18 | "loader",
19 | "react-native-css",
20 | "react-native-css-loader"
21 | ],
22 | "author": "thewei",
23 | "license": "MIT",
24 | "bugs": {
25 | "url": "https://github.com/thewei/react-native-css-loader/issues"
26 | },
27 | "homepage": "https://github.com/thewei/react-native-css-loader#readme",
28 | "dependencies": {
29 | "gulp-react-native-stylesheet-css": "^1.4.0"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015 thewei
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-native-css-loader 
2 |
3 | You can use react-native-css-loader width react-native-webpack-server, which can use webpack to built react-native app better.
4 |
5 | > react-native-css-loader, inspired by gulp-react-native-stylesheet-css, thanks.
6 |
7 | ## Installation
8 | ```bash
9 | $ npm install react-native --save
10 | $ npm install react-native-css-loader --save-dev
11 | ```
12 |
13 | ## Usage
14 | ```js
15 | var styles = require("react-native-css!./file.css");
16 | // => returns react-native stylesheet object
17 |
18 | ```
19 | Or within the webpack config:
20 | ```js
21 | // only css:
22 | module: {
23 | loaders: [{
24 | test: /\.css$/,
25 | loader: 'react-native-css-loader'
26 | }]
27 | }
28 |
29 | // use stylus:
30 | module: {
31 | loaders: [{
32 | test: /\.styl$/,
33 | loader: 'react-native-css-loader!stylus-loader'
34 | }]
35 | }
36 |
37 | // use sass:
38 | module: {
39 | loaders: [{
40 | test: /\.scss$/,
41 | loader: 'react-native-css-loader!sass-loader'
42 | }]
43 | }
44 |
45 | // use less:
46 | module: {
47 | loaders: [{
48 | test: /\.less$/,
49 | loader: 'react-native-css-loader!less-loader'
50 | }]
51 | }
52 |
53 | ```
54 |
55 | ## Properties supported
56 |
57 | Any property found in your CSS will be camelCased. By default, this plugin will always output values as JavaScript Number or Boolean objects when appropriate. Values with units attached, including "em" and "px," will be output without their unit suffixes.
58 |
59 | ### Special-case properties
60 |
61 | The following properties output different keys to satisfy React Native's requirements. Unless otherwise noted, the values for each correspond with CSS3.
62 |
63 | Property | Example Values | Notes
64 | ---------|----------------|------
65 | margin | 2px
2px 4px
3px 1px 5px
1px 3px 2px 6px |
66 | padding | 2px
2px 4px
3px 1px 5px
1px 3px 2px 6px |
67 | box-shadow | none
0 2px 4px rgba(52, 21, 23, 0.32) | Inset shadows and spread values are not supported.
68 | flex | 1
1 30px
1 2 10% | __Only the first value will be output__ and the rest will be ignored, as React Native does not support flex-basis or flex-shrink.
69 | transform | perspective(90)
rotate(10deg)
rotateX(5deg)
rotateY(10deg)
rotateZ(15deg)
rotate3d(5deg, 10deg, 15deg)
scale(1.2)
scaleX(1.5)
scaleY(0.5)
scale2d(1.5, 0.5) or scale3d(1.5, 0.5)
translateX(5px)
translateY(10px)
translate2d(5px, 10px) or translate3d(5px, 10px) | You may chain multiple transformations together with a space delimiter, like in CSS3 (see example above).
70 |
71 |
72 | ## Contributing
73 | - Fork this Repo first
74 | - Clone your Repo
75 | - Install dependencies by `$ npm install`
76 | - Checkout a feature branch
77 | - Feel free to add your features
78 | - Make sure your features are fully tested
79 | - Publish your local branch, Open a pull request
80 | - Enjoy hacking <3
81 |
--------------------------------------------------------------------------------