Skip to content

Rename project to css-modulesify #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
local-css
====
# css-modulesify

A browserify transform allowing you to `require('styles.css')` and get back locally scoped classnames.
A browserify transform to load [CSS Modules](https://github.com/css-modules/css-modules).

This is based on some ideas around [css-modules](http://github.com/css-modules), but not yet as fully-featured.
** Please note that this is still highly experimental. **

Why local css?
----
## Why CSS Modules?

Normally you need to use a strict naming convention like BEM to ensure that one component's CSS doesn't collide with another's. Locally-scoped css allows you to use names that are meaningful within the context of the component, without any danger of name collision.
Normally you need to use a strict naming convention like BEM to ensure that one component's CSS doesn't collide with another's. CSS Modules are locally scoped, which allows you to use names that are meaningful within the context of the component, without any danger of name collision.

Read Mark Dalgleish's excellent ["End of Global CSS"](https://medium.com/seek-ui-engineering/the-end-of-global-css-90d2a4a06284) and check out [css-modules](http://github.com/css-modules) for more context.

Usage
----
## Usage

First install the package: `npm install --save local-css`
First install the package: `npm install --save css-modulesify`

Then you can use it as a browserify transform, eg: `browserify -t local-css example/index.js`
Then you can use it as a browserify transform, eg: `browserify -t css-modulesify example/index.js`

Inside `example/index.js` you can now load css into your scripts. When you do `var box1 = require('./box1.css')`, `box1` will be an object to lookup the localized classname for one of the selectors in that file.

Expand All @@ -31,21 +28,21 @@ var div = `<div class="${styles.inner}">...</div>`;
To add the css to the html page there are 2 easy options:

- add the css to the DOM at runtime (good for component-based css): `require('insert-css')(require('./styles.css'))`
- export a static css file at build-time: `browserify -t local-css example/export-css.js | node > bundle.css`
- export a static css file at build-time: `browserify -t css-modulesify example/export-css.js | node > bundle.css`

Example
----
## Example

Take a look at the [example](./example/index.js) for more details, or [inspect the source](http://joshwnj.github.io/local-css/).
Take a look at the [example](./example/index.js) for more details, or [inspect the source](https://css-modules.github.io/css-modulesify/).


Licence
----
## Licence

MIT


Thanks and inspiration
----
## Thanks and inspiration

To all the fine folk working on [css-modules](https://github.com/css-modules)

----
Josh Johnston, 2015.
4 changes: 2 additions & 2 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!doctype html>
<html>
<head>
<title>Local CSS Demo</title>
<title>css-modulesify demo</title>
</head>
<body>
<h1><a href="https://github.com/joshwnj/local-css">local-css</a></h1>
<h1><a href="https://github.com/css-modules/css-modulesify">css-modulesify</a></h1>
<div id="content"></div>
<script src="dist/index.js"></script>
</body>
Expand Down
4 changes: 0 additions & 4 deletions lib/local-css.js → lib/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
var path = require('path');
var through = require('through');
var postcss = require('postcss');
var autoprefixer = require('autoprefixer-core');
var shasum = require('shasum');
var prefixSelector = require('./prefix-selector');
var FileSystemLoader = require('css-modules-loader-core/lib/file-system-loader');

var cssExt = /\.css$/;
Expand Down
22 changes: 0 additions & 22 deletions lib/prefix-selector.js

This file was deleted.

17 changes: 6 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
{
"name": "local-css",
"name": "css-modulesify",
"version": "1.1.1",
"description": "A browserify transform allowing you to `require('styles.css')` and get back locally scoped classnames.",
"main": "index.js",
"description": "A browserify transform to load CSS Modules",
"main": "lib/index.js",
"dependencies": {
"autoprefixer-core": "^5.2.0",
"css-modules-loader-core": "0.0.3",
"css-selector-tokenizer": "^0.3.1",
"postcss": "^4.1.11",
"shasum": "^1.0.1",
"through": "^2.3.7"
},
"devDependencies": {
"gh-pages": "^0.3.0",
"hyperscript": "^1.4.6",
"insert-css": "^0.2.0",
"watchify": "^3.2.1"
"insert-css": "^0.2.0"
},
"scripts": {
"build-example": "browserify -t ./lib/local-css -o example/dist/index.js example/index.js",
"export-css": "browserify -t ./lib/local-css example/export-css.js | node",
"build-example": "browserify -t ./lib -o example/dist/index.js example/index.js",
"export-css": "browserify -t ./lib example/export-css.js | node",
"publish-gh-pages": "npm run build-example && ./bin/publish-gh-pages",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down