What is the best way to include babel polyfill using multiple entry points

The easiest way would be to change

main: './resources/assets/js/main.js',
services: './resources/assets/js/services.js'

to be

main: ['babel-polyfill', './resources/assets/js/main.js'],
services: ['./resources/assets/js/services.js']

so that the polyfill is loaded and executed as part of each entry point without your files needing to know about it.

This assumes that both main and services are loaded on the same page. If they are two separate pages, you’d want the babel-polyfill entry in both arrays.

Note

The above applies to Babel 5. For Babel 6, you’d npm install --save babel-polyfill and use babel-polyfill instead of babel/polyfill.

Leave a Comment

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.