12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- var css = require('css');
- var convertSourceMap = require('convert-source-map');
- var parse = css.parse;
- var stringify = css.stringify;
- exports = module.exports = rework;
- function rework(str, options) {
- return new Rework(parse(str, options));
- }
- function Rework(obj) {
- this.obj = obj;
- }
- Rework.prototype.use = function(fn){
- fn(this.obj.stylesheet, this);
- return this;
- };
- Rework.prototype.toString = function(options){
- options = options || {};
- var result = stringify(this.obj, options);
- if (options.sourcemap && !options.sourcemapAsObject) {
- result = result.code + '\n' + sourcemapToComment(result.map);
- }
- return result;
- };
- function sourcemapToComment(map) {
- var content = convertSourceMap.fromObject(map).toBase64();
- return '/*# sourceMappingURL=data:application/json;base64,' + content + ' */';
- }
|