webpack-plugin-replace-css-url
Webpack plugin to transform download cdn urls in css and replaced with local file path
Compatible with both webpack3 and webpack4, but only work with ExtractTextPlugin or MiniCssExtractPlugin, which emit separate css
files.
Install
npm i -D webpack-plugin-replace-css-url
Usage
In your webpack.config.js
file:
const ReplaceCSSUrl = moduleexports = ... module: plugins: ... // this should be in last plugin options
All cdn urls will be downloaded to local dirs, as below rule:
{
svg: ['fonts'],
otf: ['fonts'],
ttf: ['fonts'],
eot: ['fonts'],
woff: ['fonts'],
woff2: ['fonts'],
png: ['images'],
jpg: ['images'],
gif: ['images'],
}
options.dirs
Object
object to override above folder.
options.match
String|RegExp
regexp to filter urls.
options.showLog
Boolean
default true
, you can pass false
to display nothing.