1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- 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 + ' */';
- }
|