Skip to content

Latest commit

 

History

History
30 lines (23 loc) · 579 Bytes

README.md

File metadata and controls

30 lines (23 loc) · 579 Bytes

webpack-dynamic-src

Webpack plugin that allows to configure dynamic chunk's src.

Install

npm install webpack-dynamic-src

Usage

// webpack.config.js
const WebpackDynamicSrc = require('webpack-dynamic-src');

module.exports = {
  plugins: [
    new WebpackDynamicSrc({ fn: 'dynamicSrcFn' })
  ]
}

// main.js
window.dynamicSrcFn = function (oldSrc) {
  // do something by oldSrc;
  console.log(`Original src: ${oldSrc}`);
  let chunkName = oldSrc.slice(oldSrc.lastIndexOf('/') + 1);
  return `https://www.google.com/test/${chunkName}`;
}