webpack-plugin-replace-css-url
TypeScript icon, indicating that this package has built-in type declarations

2.0.5 • Public • Published

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 = require('webpack-plugin-replace-css-url')
module.exports = {
  ...
  module: {
    plugins: [
      ...
      // this should be in last plugin
      new ReplaceCSSUrl(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.

Package Sidebar

Install

npm i webpack-plugin-replace-css-url

Weekly Downloads

148

Version

2.0.5

License

MIT

Unpacked Size

8.81 kB

Total Files

7

Last publish

Collaborators

  • cssobj