| // Copyright 2015 The Vanadium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| var through2 = require('through2'); |
| var path = require('path'); |
| var rework = require('rework'); |
| var reworkVars = require('rework-vars'); |
| var reworkImport = require('rework-import'); |
| * Transform the given css file by compiling it with rework. |
| function transform(file) { |
| return through2(write, flush); |
| // Simply collect string fragments of the css file. |
| function write(data, encoding, callback) { |
| var string = data.toString(); |
| // Reconstruct the css and then compile it. |
| function flush(callback) { |
| var string = contents.join(''); |
| var css = compile(string); |
| this.push('module.exports = ' + JSON.stringify(css)); |
| /* Compiles the given CSS string using rework. */ |
| function compile(string) { |
| /* Determines if the filetype is css. */ |
| return path.extname(file) === '.css'; |