Skip to content

Commit

Permalink
Fix docs, version, map option
Browse files Browse the repository at this point in the history
  • Loading branch information
Ser-Gen committed Dec 14, 2015
1 parent f362cfb commit 528fc07
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ dataPacker({
})
```

You can use functions as values of `dest.path` and `dest.path.map.annotation`. This functions must return strings.
Example (from #13):

```js
dataPacker({
dest: {
path: function (opts) {
return path.join('build/css', path.basename(opts.from, '.css') + '.data.css');
}
}
})
```


### Using

Expand Down
13 changes: 13 additions & 0 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ dataPacker({
})
```

Значениями параметров `dest.path` и `dest.path.map.annotation` также могут быть функции, которые должны возвращать строку.
Пример использования (из #13):

```js
dataPacker({
dest: {
path: function (opts) {
return path.join('build/css', path.basename(opts.from, '.css') + '.data.css');
}
}
})
```


### Подключение

Expand Down
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function generateDataFile (css, opts) {

var data = dataCSS.toResult({
to: (typeof opts.dest.path === 'function') ? opts.dest.path(opts) : opts.dest.path,
map: (typeof opts.dest.map === 'function') ? opts.dest.map(opts) : opts.dest.map
map: opts.dest.map
});

if (!data.css.length) return;
Expand All @@ -201,6 +201,7 @@ function extend (target, source) {
Object.keys(source).map(function (prop) {
prop in a && (a[prop] = source[prop]);
});

return a;
};

Expand Down Expand Up @@ -241,7 +242,8 @@ function getMapPath (opts) {
var result;

if (opts.map.annotation) {
result = path.dirname(opts.to) +'/'+ opts.map.annotation;
result = (typeof opts.map.annotation === 'function') ? opts.map.annotation(opts) : opts.map.annotation;
result = path.join(path.dirname(opts.to), result);
}
else {
result = opts.to +'.map';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-data-packer",
"version": "1.1.0",
"version": "1.2.0",
"description": "PostCSS plugin to move an embedded data into a separate file",
"keywords": [
"css",
Expand Down

0 comments on commit 528fc07

Please sign in to comment.