css-fix-url-loader
Webpack loader to transform URLs to other URLs in CSS. Fork from css-url-loader
Description
Transform URLs to other URLs in the url()
s in your CSS. You can change relative urls
to absolute urls, or absolute urls to relative urls, or you can change old urls to new urls that you want.
Install
npm install --save-dev css-fix-url-loader
Or
yarn add --dev css-fix-url-loader
Usage
url(/assets/...)
to url(https://domain/assets/...)
, the webpack.config.js
is below
When you want to trasform moduleexports = ... module: rules: ... test: /\.css$/ use: ExtractTextPlugin ... plugins: ... 'bundle.css' ...
url(/assets/...)
to url(/dir/assets/...)
, the webpack.config.js
is below
When you want to trasform moduleexports = ... module: rules: ... test: /\.css$/ use: ExtractTextPlugin ... plugins: ... 'bundle.css' ...
webpack.config.js
is below
When you want to trasform urls when only development, the moduleexports = ... module: rules: ... test: /\.css$/ use: ExtractTextPlugin ... plugins: ... 'bundle.css' ...
webpack.config.js
is below
When you want to trasform urls from absolute to relative, the moduleexports = ... module: rules: ... test: /\.css$/ use: ExtractTextPlugin ... plugins: ... 'bundle.css' ...
Options
Option | Description | Required |
---|---|---|
from | original url in url() | Y |
to | transformed url | Y |
env | value to control execution timing with process.env.NODE_ENV . Default is 'production'. |
N |
relative | if need to trasform urls from absolute to relative | N |