UNPKG

1.75 kBJavaScriptView Raw
1/**
2 * Here are the tags used by a CSS source:
3 * * __`debug`__: (string) CSS code after LESS expansion.
4 * * __`release`__: (string) CSS LESS expanded code after zip.
5 * * __`resources`__: (array) resources referenced by this CSS: images, fonts, ...
6 * @module compiler-css
7 */
8
9var FS = require("fs");
10var Path = require("path");
11var Util = require("./util");
12//var Vars = require('rework-vars');
13var Rework = require('rework');
14
15/**
16 * @todo Parse the `release` looking for `url(...)` in order to list all resources.
17 */
18module.exports.compile = function(source) {
19 if (source.isUptodate()) return false;
20 console.log("Compiling CSS " + source.name().yellow);
21 var content = source.read();
22 //var multiBrowserContent = Rework( content ).use( Vars({}) ).toString();
23 var multiBrowserContent = Rework( content ).use().toString();
24 var debug = multiBrowserContent;
25 var release = Util.zipCSS(multiBrowserContent).styles;
26 source.tag("debug", debug);
27 source.tag("release", release);
28 source.save();
29};
30
31/**
32 * Macro processing for CSS.
33 *
34 * This code:
35 * ```
36 * <mac:keyframes name="my_anim">
37 * @keyframes {{name}} {{{@}}}
38 * @-webkit-keyframes {{name}} {{{@}}}
39 * </mac:frames>
40 *
41 * <keyframes name="horizontal-slide">
42 * from { margin-left: 100%; }
43 * to { margin-left: 0%; }
44 * </mac:frames>
45 * ```
46 *
47 * will give this result:
48 * ```
49 * @keyframes horizontal-slide {
50 * from { margin-left: 100%; }
51 * to { margin-left: 0%; }
52 * }
53 * @-webkit-keyframes horizontal-slide {
54 * from { margin-left: 100%; }
55 * to { margin-left: 0%; }
56 * }
57 * ```
58 */
59module.exports.macroCSS = function(content, macros) {
60 if (typeof macros === 'undefined') macros = {};
61
62
63}