node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »

simple-rework-loader

simple-rework-loader

Simple webpack 2 loader for CSS post-processing with Rework.

Installation

npm install --save-dev simple-rework-loader

Usage

Add to your webpack config file and use in module.rules.

const reworkLoader = require('simple-rework-loader');

Configuration

// 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.

License

MIT