You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # rework-import [![Build Status](http://img.shields.io/travis/reworkcss/rework-import.svg?style=flat)](https://travis-ci.org/reworkcss/rework-import)
  2. > Import stylesheets using `@import` and an optional media query
  3. ## Install
  4. ```bash
  5. $ npm install --save rework-import
  6. ```
  7. ## Usage
  8. ```js
  9. var data = require('fs').readFileSync('index.css');
  10. var imprt = require('rework-import');
  11. var rework = require('rework');
  12. rework(data)
  13. .use(imprt({path: 'app/stylesheets'}))
  14. .toString();
  15. ```
  16. ## Options
  17. ### encoding
  18. Type: `String`
  19. Default: `utf8`
  20. Use if your CSS is encoded in anything other than `UTF-8`.
  21. ### path
  22. Type: `Array|String`
  23. Default: `process.cwd()` or `__dirname` of [the rework source](https://github.com/reworkcss/css#cssparsecode-options)
  24. A string or an array of paths in where to look for files.
  25. _Note: nested `@import` will additionally benefit of the relative dirname of imported files._
  26. ### transform
  27. Type: `Function`
  28. A function to transform the content of imported files. Takes one argument and should return the modified content. Useful if you use [`css-whitespace`](https://github.com/reworkcss/css-whitespace).
  29. ## Example
  30. ```css
  31. @import 'foo.css' (min-width: 25em);
  32. body {
  33. background: black;
  34. }
  35. ```
  36. yields:
  37. ```css
  38. @media (min-width: 25em) {
  39. body {
  40. background: red;
  41. }
  42. h1 {
  43. color: grey;
  44. }
  45. }
  46. body {
  47. background: black;
  48. }
  49. ```
  50. ## License
  51. MIT © [Jason Campbell](https://github.com/jxson) and [Kevin Mårtensson](http://github.com/kevva)