From 929708f4dbe65d7e5e4973a74d590c143b441e50 Mon Sep 17 00:00:00 2001 From: Yannick Ihmels Date: Wed, 10 Jul 2019 14:15:21 +0200 Subject: [PATCH] Add babel option to pre-include polyfills --- index.js | 3 +++ lib/WebpackConfig.js | 1 + lib/loaders/babel.js | 1 + 3 files changed, 5 insertions(+) diff --git a/index.js b/index.js index ee6232f7..b54a794f 100644 --- a/index.js +++ b/index.js @@ -848,6 +848,9 @@ class Encore { * // core-js to your project using Yarn or npm and * // inform Babel of the version it will use. * corejs: 3 + * + * // pre-include needed polyfills + * polyfills: [] * }); * ``` * diff --git a/lib/WebpackConfig.js b/lib/WebpackConfig.js index 0455718d..5678a3e7 100644 --- a/lib/WebpackConfig.js +++ b/lib/WebpackConfig.js @@ -128,6 +128,7 @@ class WebpackConfig { exclude: /(node_modules|bower_components)/, useBuiltIns: false, corejs: null, + polyfills: [], }; this.vueOptions = { useJsx: false, diff --git a/lib/loaders/babel.js b/lib/loaders/babel.js index 6ed2e30b..31469682 100644 --- a/lib/loaders/babel.js +++ b/lib/loaders/babel.js @@ -45,6 +45,7 @@ module.exports = { forceAllTransforms: webpackConfig.isProduction(), useBuiltIns: webpackConfig.babelOptions.useBuiltIns, corejs: webpackConfig.babelOptions.corejs, + include: webpackConfig.babelOptions.polyfills, }; Object.assign(babelConfig, {