postcss / postcss-url

PostCSS plugin to rebase url(), inline or copy asset.
MIT License
377 stars 59 forks source link

Plugin's options parameter is now required (breaking change since v6) #87

Closed elisherer closed 7 years ago

elisherer commented 7 years ago

I used postcss-url as-is no custom options (not passing an options object). Now i'm required to pass an empty object because otherwise I fail an options.url check as soon as replaceUrl is called in the index.js file.

plugin:

module.exports = postcss.plugin('postcss-url', (options) =>
...
            return declProcessor(options, result, dir, decl);
...
);

declProcessor:

const declProcessor = (options, result, dir, decl) => {
...
            const newUrl = replaceUrl(url, dir, options, result, decl);
...
};

replaceUrl:

const replaceUrl = (url, dir, options, result, decl) => {
    const isFunction = typeof options.url === 'function';
                                      ^ fails here!
...
};

I think a simple

module.exports = postcss.plugin('postcss-url', (options = {}) =>

should solve it.

sergcen commented 7 years ago

@elisherer thanks for feedback, now i will fix it

sergcen commented 7 years ago

@elisherer done!