Pour is a minimalist CSS bundler (~100 LOC). It leaves your CSS files completely alone except for one rule:
@import (inline) "./my-file.css"
Upon seeing this syntactically-invalid rule, Pour will resolve, read, and inline the contents of that file in place of the rule.
Pour does not minify or process your CSS in any way – there are already dedicated tools for that. Pour does one thing and it does it well.
You might not need SASS (common installation problems), LESS (poor tooling), or PostCSS (complex setup). CSS has become quite mature out-of-the-box. Did you know browsers now widely support...
yarn install pour-css
# or
npm install pour-css
You can use Pour via the command line or its JavaScript API.
pour my/style.css > bundle.css
Pour exposes a bundle
function that takes a file path and returns a stream.
var Pour = require('pour-css');
You can pipe to a file...
Pour.bundle(__dirname + '/css/index.css')
.pipe(fs.createWriteStream('bundle.css'));
...or pipe to a HTTP response!
var http = require('http')
http.createServer((req, res) => {
if ( req.method === 'GET' && req.url === '/style.css' ) {
Pour.bundle(__dirname + '/css/index.css')
.pipe(res);
}
// ...
});
If you're mixing @import
and @import (inline)
, be careful about how you order them. According to the official CSS spec, all @import
rules must precede all other rules in your stylesheet. In practice, any @import
rule that doesn't follow the spec is ignored by the browser.
What does this mean for you? Just use these two rules of thumb and you should be good:
- Don't
@import (inline)
a file that contains normal@import
statements (or be very careful about it) - Put all
@import (inline)
statements after your normal@import
statements (if you have any).
If you're adding a feature or fixing a bug, clone this repo down, npm install
, and use the following to run the test suite:
npm test