Skip to content

Commit 6b6a0b7

Browse files
committed
Initial commit
0 parents  commit 6b6a0b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3411
-0
lines changed

.babelrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": [
3+
"es2015"
4+
]
5+
}

.eslintrc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"parser": "babel-eslint",
3+
"rules": {
4+
"strict": [2, "never"],
5+
"quotes": [2, "single", "avoid-escape"],
6+
"no-multi-spaces": 0,
7+
"no-use-before-define": [2, "nofunc"]
8+
},
9+
"env": {
10+
"node": true
11+
}
12+
}

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/coverage
2+
/lib
3+
/node_modules
4+
/tmp

.npmignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/.babelrc
2+
/.eslintrc
3+
/.gitignore
4+
/.npmignore
5+
/.travis.yml
6+
/coverage
7+
/example
8+
/src
9+
/tmp
10+
/test
11+
/CHANGELOG.md
12+
/Makefile

.travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: node_js
2+
node_js:
3+
- "0.12"
4+
- "4"
5+
- "5"
6+
before_script: "npm install -g codeclimate-test-reporter"
7+
script: "make test-cov"
8+
after_script: "cat coverage/lcov.info | codeclimate"
9+
addons:
10+
code_climate:
11+
repo_token: 24a4c47918bae008a97ac96b8a4c3f16ca4bc684480f95f802b6ff5429953ab9

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Changelog
2+
3+
Tags:
4+
5+
- [New Feature]
6+
- [Bug Fix]
7+
- [Breaking Change]
8+
- [Documentation]
9+
- [Internal]
10+
- [Polish]
11+
12+
## 0.0.1 (November 8, 2015)
13+
14+
First public release.

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Martin Andert
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
13+
all 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
21+
THE SOFTWARE.

Makefile

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
BIN = ./node_modules/.bin
2+
3+
SRC_JS = $(shell find src/ -name "*.js")
4+
LIB_JS = $(patsubst src/%.js,lib/%.js,$(SRC_JS))
5+
6+
build: node_modules/ $(LIB_JS)
7+
8+
$(LIB_JS): lib/%.js: src/%.js
9+
@mkdir -p $(dir $@)
10+
BABEL_ENV=build $(BIN)/babel $< --out-file $@
11+
12+
fast: node_modules/
13+
@BABEL_ENV=build $(BIN)/babel src/ --out-dir lib/
14+
15+
watch: node_modules/
16+
BABEL_ENV=build $(BIN)/babel src/ --out-dir lib/ --watch
17+
18+
lint: node_modules/
19+
@$(BIN)/eslint src/
20+
21+
test: lint build
22+
@NODE_ENV=test $(BIN)/mocha
23+
24+
test-cov:
25+
@NODE_ENV=test $(BIN)/babel-node $(BIN)/babel-istanbul cover $(BIN)/_mocha
26+
27+
node_modules/:
28+
@npm install
29+
30+
clean:
31+
@rm -rf lib/ tmp/cache/build/
32+
33+
distclean: clean
34+
@rm -rf tmp/ node_modules/ coverage/
35+
36+
release-patch: test
37+
@$(call release,patch)
38+
39+
release-minor: test
40+
@$(call release,minor)
41+
42+
release-major: test
43+
@$(call release,major)
44+
45+
publish:
46+
git push --tags origin HEAD:master
47+
npm publish
48+
49+
define release
50+
npm version $(1) -m 'release v%s'
51+
endef
52+
53+
.PHONY: build fast watch lint test test-cov clean distclean release-patch release-minor release-major publish

README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# babel-plugin-css-in-js
2+
3+
[![build status](https://img.shields.io/travis/martinandert/babel-plugin-css-in-js.svg?style=flat-square)](https://travis-ci.org/martinandert/babel-plugin-css-in-js)
4+
[![code climate](https://img.shields.io/codeclimate/github/martinandert/babel-plugin-css-in-js.svg?style=flat-square)](https://codeclimate.com/github/martinandert/babel-plugin-css-in-js)
5+
[![test coverage](https://img.shields.io/codeclimate/coverage/github/martinandert/babel-plugin-css-in-js.svg?style=flat-square)](https://codeclimate.com/github/martinandert/babel-plugin-css-in-js)
6+
[![npm version](https://img.shields.io/npm/v/babel-plugin-css-in-js.svg?style=flat-square)](https://www.npmjs.com/package/babel-plugin-css-in-js)
7+
8+
TODO: introduction
9+
10+
11+
## Usage
12+
13+
TODO: usage instruction
14+
15+
16+
## Installation
17+
18+
TODO: installation instructions
19+
20+
21+
## Example
22+
23+
TODO: example description
24+
25+
26+
## Contributing
27+
28+
1. Fork it ( https://github.com/martinandert/babel-plugin-css-in-js )
29+
2. Run `npm install` to install dependencies.
30+
3. Run the tests. We only take pull requests with passing tests, and it's great to know that you have a clean slate: `make test`.
31+
4. Create your feature branch (`git checkout -b my-new-feature`)
32+
5. Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or are fixing a bug, we need a test!
33+
6. Make the test pass.
34+
7. Commit your changes (`git commit -am 'add some feature'`)
35+
8. Push to your fork (`git push origin my-new-feature`)
36+
9. Create a new Pull Request
37+
38+
39+
## License
40+
41+
Released under The MIT License.

example/.babelrc

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"react"
5+
],
6+
"plugins": [
7+
"transform-node-env-inline"
8+
],
9+
"env": {
10+
"development": {
11+
"plugins": [
12+
["css-in-js", {
13+
"mediaMap": {
14+
"phone": "media only screen and (max-width: 640px)"
15+
},
16+
"bundleFile": "public/bundle.css"
17+
}]
18+
]
19+
},
20+
"production": {
21+
"plugins": [
22+
["css-in-js", {
23+
"minify": true,
24+
"compressClassNames": true,
25+
"mediaMap": {
26+
"phone": "media only screen and (max-width: 640px)"
27+
},
28+
"bundleFile": "public/bundle.css"
29+
}]
30+
]
31+
}
32+
}
33+
}

example/.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/lib
2+
/node_modules
3+
/public/bundle.css
4+
/public/bundle.js
5+
/tmp

example/Capfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require "capistrano/setup"
2+
require "capistrano/deploy"
3+
require "capistrano/yutiriti"

example/Makefile

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
BIN = ./node_modules/.bin
2+
3+
BABEL_OPTS = src/ --out-dir lib/
4+
WEBPACK_OPTS = --debug --output-pathinfo --colors
5+
6+
build: node_modules/ webpack
7+
$(BIN)/babel $(BABEL_OPTS)
8+
9+
build-production: node_modules/ webpack-production
10+
NODE_ENV=production $(BIN)/babel $(BABEL_OPTS)
11+
12+
webpack:
13+
$(BIN)/webpack $(WEBPACK_OPTS)
14+
15+
webpack-production:
16+
NODE_ENV=production $(BIN)/webpack
17+
18+
watch: node_modules/
19+
bin/parallel "$(BIN)/babel $(BABEL_OPTS) --watch" "$(BIN)/webpack $(WEBPACK_OPTS) --watch"
20+
21+
run: clean build
22+
node .
23+
24+
run-production: clean build-production
25+
NODE_ENV=production node .
26+
27+
node_modules/:
28+
npm install
29+
30+
clean:
31+
@rm -rf tmp/ lib/ public/bundle.*
32+
33+
distclean: clean
34+
@rm -rf node_modules/
35+
36+
publish:
37+
cap production deploy deploy:restart
38+
39+
.PHONY: build build-production watch webpack webpack-production run run-production clean distclean publish

example/Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: node .

example/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# babel-plugin-css-in-js Example Project
2+
3+
TODO: introduction
4+
5+
6+
See the Makefile for details.
7+
8+
To run it in development environment, execute
9+
10+
```bash
11+
$ make run
12+
```
13+
14+
To run it in production environment (which compresses and minifies CSS and class names), execute
15+
16+
```bash
17+
$ make run-production
18+
```
19+
20+
After that, point your web browser to `http://localhost:3000`.
21+
22+
Use your browser's "Inspect Element" tool to see how all styles were turned into class names.

example/bin/parallel

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
for cmd in "$@"; do {
4+
$cmd & pid=$!
5+
PID_LIST+=" $pid";
6+
} done
7+
8+
trap "kill $PID_LIST" SIGINT
9+
wait $PID_LIST

example/config/deploy.rb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
lock "3.4.0" # valid only for current version of Capistrano
2+
3+
set :application, "babel-plugin-css-in-js-demo"
4+
set :log_level, :debug
5+
set :keep_releases, 3
6+
7+
set :repo_url, "[email protected]:martinandert/babel-plugin-css-in-js.git"
8+
set :repo_tree, "example"
9+
10+
set :buildpack_url, "https://github.com/heroku/heroku-buildpack-nodejs.git#v75"
11+
set :foreman_options, port: 3016, user: "deploy"
12+
set :default_env, npm_config_production: "false", node_env: "production"

example/config/deploy/production.rb

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
server "do1", roles: %w(web app db)

example/package.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "bable-plugin-css-in-js-example",
3+
"version": "1.0.0",
4+
"private": true,
5+
"main": "./lib/server.js",
6+
"scripts": {
7+
"postinstall": "test \"$NODE_ENV\" = production && make build-production; true"
8+
},
9+
"dependencies": {
10+
"classnames": "^2.2.0",
11+
"compression": "^1.6.0",
12+
"ejs": "^2.3.4",
13+
"errorhandler": "^1.4.2",
14+
"express": "^4.13.3",
15+
"morgan": "^1.6.1",
16+
"react": "^0.14.2",
17+
"react-dom": "^0.14.2",
18+
"serve-favicon": "^2.3.0",
19+
"static-expiry": "0.0.11"
20+
},
21+
"devDependencies": {
22+
"babel-cli": "^6.1.2",
23+
"babel-core": "^6.1.2",
24+
"babel-loader": "^6.0.1",
25+
"babel-plugin-css-in-js": "..",
26+
"babel-plugin-transform-node-env-inline": "^6.0.14",
27+
"babel-preset-es2015": "^6.1.2",
28+
"babel-preset-react": "^6.1.2",
29+
"webpack": "^1.12.3"
30+
}
31+
}

example/public/favicon.ico

Whitespace-only changes.

example/public/global.css

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
* {
2+
box-sizing: border-box;
3+
}
4+
5+
h1 {
6+
background-color: #666;
7+
color: white;
8+
margin: 0;
9+
padding: 10px;
10+
font-size: 20px;
11+
line-height: 1;
12+
text-align: center;
13+
}
14+
15+
h2, h3, h4, h5, h6 {
16+
margin-top: 45px;
17+
margin-bottom: 15px;
18+
}
19+
20+
div, p, ul, ol, li, table {
21+
margin-top: 0;
22+
margin-bottom: 15px;
23+
}
24+
25+
div:last-child, p:last-child, ul:last-child, ol:last-child, li:last-child, table:last-child {
26+
margin-bottom: 0;
27+
}

0 commit comments

Comments
 (0)