Simple webpack 2 loader for CSS post-processing with Rework.
npm install --save-dev simple-rework-loader
Add to your webpack config file and use in module.rules
.
const reworkLoader = require('simple-rework-loader');
// Add plugins
const reworkPluginUrl = require('rework-plugin-url');
function changeImageUrls(url) {
return url.replace(/^(\.\.\/)*images\//, '/assets/images/');
}
// Write rules
module.exports = {
// <...>
module: {
rules: [
{
test: /\.css$/,
use: [{
loader: reworkLoader,
options: {
plugins: [reworkPluginUrl(changeImageUrls)]
}
}]
}
]
}
}
options.plugins
accepts an array of functions or a function. Plugins are applied right to left.