From 05bc41389f5306c8d3ee090b8db4e8799b11e855 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford Date: Tue, 8 Jan 2019 14:35:50 -0800 Subject: [PATCH] Autodetect electron version for @babel/preset-env --- webpack.makeConfig.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webpack.makeConfig.js b/webpack.makeConfig.js index 2b80475..5399438 100644 --- a/webpack.makeConfig.js +++ b/webpack.makeConfig.js @@ -1,8 +1,14 @@ +const childProcess = require('child_process'); + +const electronPath = require('electron'); const webpack = require('webpack'); const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const isProduction = (process.env.NODE_ENV === 'production'); +const electronVersion = childProcess.execSync(`${electronPath} --version`, {encoding: 'utf8'}).trim(); +console.log(`Targeting Electron ${electronVersion}`); + const makeConfig = function (options) { // eslint-disable-next-line no-console console.log(`Module "${options.name}" building in production mode? ${isProduction}`); @@ -16,7 +22,7 @@ const makeConfig = function (options) { '@babel/plugin-proposal-object-rest-spread' ], presets: [ - ['@babel/preset-env', {targets: {electron: '3.0.13'}}] + ['@babel/preset-env', {targets: {electron: electronVersion}}] ] };