A Webpack plugin that works with Babel to enable differential loading - producing ES2015 builds for modern browsers with an ES5 fallback for legacy browsers. Current stable version is 2.5.0. The plugin integrates with html-webpack-plugin (^3.2.0 || ^4.0.0), terser (>=3.12.0), webpack (^4.19.0), and webpack-dev-server (^3.1.0). It ships TypeScript types. Key differentiators: automates the dual-build setup described by Philip Walton, avoids manual configuration of multiple webpack entries, and natively handles Safari 10 noModule fix injection.
npm install webpack-babel-multi-target-pluginVerified import paths — ran on the pinned version, not inferred.
Minimal webpack configuration using BabelMultiTargetPlugin for differential loading. Replace babel-loader with BabelMultiTargetPlugin.loader(), set resolve.mainFields, and add the plugin.
Remove any exclude patterns for node_modules from rules using BabelMultiTargetPlugin.loader().
Upgrade html-webpack-plugin to ^3.2.0 || ^4.0.0.
Replace all instances of 'babel-loader' with BabelMultiTargetPlugin.loader(). Remove babel-loader from package.json dependencies (it's a dependency of the plugin).
Either use HtmlWebpackPlugin or set BabelMultiTargetPlugin options to disable the fix: { safari10NoModuleFix: false }.Example: use: ['ts-loader', BabelMultiTargetPlugin.loader()].
Reorder rules so expose-loader comes first, and avoid import statements for exposed globals.
Remove babel-loader from your package.json; it is a dependency of the plugin. Run npm install to ensure the plugin's version is used.
Use const BabelMultiTargetPlugin = require('webpack-babel-multi-target-plugin');Replace all uses of 'babel-loader' with BabelMultiTargetPlugin.loader().
Remove hash: true from HtmlWebpackPlugin options; use contenthash in output filenames instead.