Skip to content

1.2.1

Compare
Choose a tag to compare
@Ser-Gen Ser-Gen released this 15 Dec 09:12
· 2 commits to master since this release

Options of function in dest.map.annotation have become richer.
For example, now you can set filenames only in opts of postcss.process():

var fs = require('fs');
var path = require('path');

require('postcss')([
    require('postcss-data-packer')({
        dest: {
            path: function (opts) {
                return path.join(path.dirname(opts.to), path.basename(opts.to, '.css') + '.data.css');
            },
            map: {
                inline: false,
                annotation: function (dataOpts, opts) {
                    return path.join(path.dirname(opts.map.annotation), path.basename(dataOpts.to) +'.map');
                }
            }
        }
    })
])
.process(fs.readFileSync('_main.css'), {
    from: '_main.css',
    to: 'css/main.css',
    map: {
        inline: false,
        annotation: 'css/maps/main.css.map'
    }
})
.then(function (result) {

    fs.writeFileSync(result.opts.to, result.css);

    if ( result.map ) {
        fs.writeFileSync(result.opts.map.annotation, result.map);
    };

});

After executing you will get:

[cwd]
├── css
│   ├── maps
│   |   ├── main.css.map
│   |   └── main.data.css.map
│   ├── main.css
│   └── main.data.css
└── _main.css