Skip to content

Commit

Permalink
feat(dependencies): 2.0.0 and dropped deprecated sourcemap
Browse files Browse the repository at this point in the history
  • Loading branch information
lubber-de committed Oct 28, 2022
1 parent 610027a commit f842226
Show file tree
Hide file tree
Showing 7 changed files with 612 additions and 60 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
.vscode
.idea
6 changes: 6 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2.0.0 / 2022-10-28
==================

* Switched from `css` to `@adobe/css-tools` which in turn drops deprecated sourceMap support
* updated dependencies.

1.0.1 / 2014-08-28
==================

Expand Down
9 changes: 4 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# rework [![Build Status](https://travis-ci.org/reworkcss/rework.png)](https://travis-ci.org/reworkcss/rework)

> ### Forked Version using updated dependencies and dropped sourceMap support
> Original repo at https://github.com/reworkcss/rework
CSS manipulations built on [`css`](https://github.com/reworkcss/css), allowing
you to automate vendor prefixing, create your own properties, inline images,
anything you can imagine!
Expand All @@ -21,7 +24,7 @@ var pluginB = require('pluginB');
rework('body { font-size: 12px; }', { source: 'source.css' })
.use(pluginA)
.use(pluginB)
.toString({ sourcemap: true })
.toString()
```

## API
Expand All @@ -41,10 +44,6 @@ stylesheet root node and the `Rework` instance.
Returns the string representation of the manipulated CSS. The `options` are
passed directly to `css.stringify`.

Unlike `css.stringify`, if you pass `sourcemap: true` a string will still be
returned, with the source map inlined. Also use `sourcemapAsObject: true` if
you want the `css.stringify` return value.

## Plugins

Rework has a rich collection of plugins and mixins. Browse all the [Rework
Expand Down
18 changes: 1 addition & 17 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* Module dependencies.
*/

var css = require('css');
var convertSourceMap = require('convert-source-map');
var css = require('@adobe/css-tools');
var parse = css.parse;
var stringify = css.stringify;

Expand Down Expand Up @@ -62,21 +61,6 @@ Rework.prototype.use = function(fn){
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;
};

/**
* Convert sourcemap to base64-encoded comment
*
* @param {Object} map
* @return {String}
* @api private
*/

function sourcemapToComment(map) {
var content = convertSourceMap.fromObject(map).toBase64();
return '/*# sourceMappingURL=data:application/json;base64,' + content + ' */';
}
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
{
"name": "rework",
"version": "1.0.1",
"name": "@fomantic/rework",
"version": "2.0.0",
"description": "Plugin framework for CSS preprocessing",
"main": "index",
"files": [
"index.js"
],
"dependencies": {
"css": "^2.0.0",
"convert-source-map": "^0.3.3"
"@adobe/css-tools": "^4.0.1"
},
"devDependencies": {
"mocha": "^1.20.1",
"should": "^4.0.4"
"mocha": "^9.2.2",
"should": "^13.2.3"
},
"scripts": {
"test": "mocha --require should --reporter spec"
Expand All @@ -27,7 +26,7 @@
"author": "TJ Holowaychuk <tj@vision-media.ca>",
"repository": {
"type": "git",
"url": "git://github.com/reworkcss/rework.git"
"url": "git://github.com/fomantic/rework.git"
},
"license": "MIT"
}
31 changes: 0 additions & 31 deletions test/rework.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,4 @@ describe('rework', function() {
});
});

describe('.toString() sourcemap option', function() {
it('should inline sourcemap', function() {
var result = rework('body { color: red; }').toString({
compress: true,
sourcemap: true
});

result.should.equal(
'body{color:red;}' + '\n' +
'/*# sourceMappingURL=data:application/json;base64,' +
'eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNvdXJjZS5jc3MiXSwibmFtZXMiOltdL' +
'CJtYXBwaW5ncyI6IkFBQUEsS0FBTyIsInNvdXJjZXNDb250ZW50IjpbImJvZHkgey' +
'Bjb2xvcjogcmVkOyB9Il19 */'
);
});
});

describe('.toString() sourcemapAsObject and sourcemap options', function() {
it('should return sourcemap as an object', function() {
var result = rework('body { color: red; }').toString({
compress: true,
sourcemap: true,
sourcemapAsObject: true
});

result.code.should.equal('body{color:red;}');
result.map.should.have.property('mappings');
result.map.mappings.should.equal('AAAA,KAAO');
});
});

});
Loading

0 comments on commit f842226

Please sign in to comment.