How to use the ReplaceCodePlugin function from webpack

Find comprehensive JavaScript webpack.ReplaceCodePlugin code examples handpicked from public code repositorys.

139
140
141
142
143
144
145
146
147
148
  new BannerPlugin({
    banner: '#!/usr/bin/env node\nrequire("v8-compile-cache");',
    raw: true,
    test: /\bcli\.js$/,
  }),
  new ReplaceCodePlugin([
    { search: /( require\("\.\/)vendor\//g, replace: '$1', test: /\bvendor[\\/][\w-]*\.js$/ }, //
  ]),
],
optimization: {
fork icon0
star icon0
watch icon1

106
107
108
109
110
111
112
113
114
115
        {
          from: 'node_modules/import-local/package.json',
          transform: (content) => String(content).replace(/,\s*"(d(evD)?ependencies|scripts|xo)": *\{[^{}]*\}/g, ''),
        },
      ]),
      new ReplaceCodePlugin({ search: ' require("./originalRequire")', replace: ' require' }),
    ],
  }),
  */
];
fork icon0
star icon0
watch icon0