Loader for webpack.
Replaces the relative paths in the css files in the path relative to the root directory of the application. The root parameter is required.
const root = '/projects/angular2/';
// wepback.config.js
...
{
test: /.less$/,
exclude: /node_modules/,
loader: ['raw-loader', 'less-loader', 'css-relative-url-loader?root=' + root]
}
components
|
| my-component
| |
| | assets
| | |
| | | my-image.jpg
| | |
| | css
| | |
| | | style.css
background: url('./../assets/my-image.jpg');
will be replace with -> background: url('components/my-component/assets/my-image.jpg');