From ac4f477576506dbd73a37227cc0c13792bae1d0f Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Fri, 29 May 2020 16:44:46 -0400 Subject: [PATCH 1/2] better load webpack config --- package-lock.json | 6 +++--- package.json | 2 +- plugins/load-webpack/index.js | 13 +++++-------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index c0766e08..1d5fc1db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13905,9 +13905,9 @@ } }, "find-webpack": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/find-webpack/-/find-webpack-1.9.2.tgz", - "integrity": "sha512-dP/8arVmdcHvB0KwTjLDdifSE/8/kkRbrok6tdBWyTOTlBx+M2otk8lk5CMidOd2wJZH6k5TR5Hc+bsyhhZVRA==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/find-webpack/-/find-webpack-1.10.0.tgz", + "integrity": "sha512-5EI/dXzTCsO0TT2jAd86aiXffNoAXEr28hjGRHPea8qnQnUpRl2RPKt3eIEVFu0G6l6lqXc+s2UrNF62LxyCIg==", "requires": { "debug": "4.1.1", "find-yarn-workspace-root": "1.2.1", diff --git a/package.json b/package.json index 044902d6..4b74e710 100644 --- a/package.json +++ b/package.json @@ -126,7 +126,7 @@ "@cypress/webpack-preprocessor": "5.4.1", "babel-plugin-istanbul": "6.0.0", "debug": "4.1.1", - "find-webpack": "1.9.2", + "find-webpack": "1.10.0", "mime-types": "2.1.26" }, "release": { diff --git a/plugins/load-webpack/index.js b/plugins/load-webpack/index.js index 90e0d534..f74138f1 100644 --- a/plugins/load-webpack/index.js +++ b/plugins/load-webpack/index.js @@ -16,14 +16,11 @@ module.exports = (on, config) => { } debug('got webpack config filename %s', webpackFilename) const resolved = path.resolve(webpackFilename) - debug('resolved webpack at %s', webpackFilename) - - let webpackOptions = require(resolved) - debug('loaded webpack options: %o', webpackOptions) - if (webpackOptions.default) { - // we probably loaded TS file - debug('loaded webpack options has .default - taking that as the config') - webpackOptions = webpackOptions.default + debug('resolved webpack at %s', resolved) + + const webpackOptions = findWebpack.tryLoadingWebpackConfig(resolved) + if (!webpackOptions) { + throw new Error(`Could not load webpack config from ${resolved}`) } debug('webpack options: %o', webpackOptions) From 886a7cd762bd371659c74f1600ad2a15d4ecac67 Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Fri, 29 May 2020 16:57:17 -0400 Subject: [PATCH 2/2] keep environment name --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1d5fc1db..caf91e27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13905,9 +13905,9 @@ } }, "find-webpack": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/find-webpack/-/find-webpack-1.10.0.tgz", - "integrity": "sha512-5EI/dXzTCsO0TT2jAd86aiXffNoAXEr28hjGRHPea8qnQnUpRl2RPKt3eIEVFu0G6l6lqXc+s2UrNF62LxyCIg==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/find-webpack/-/find-webpack-1.10.1.tgz", + "integrity": "sha512-0ze0B7GUw9mC/UPXJUTPwjjGtr2RAT13OKq6uy373oLkVtu3S7UkgzxfI/sxY2Ot1XVl6/tPTzffms0YUTpfxA==", "requires": { "debug": "4.1.1", "find-yarn-workspace-root": "1.2.1", diff --git a/package.json b/package.json index 4b74e710..2525c9ac 100644 --- a/package.json +++ b/package.json @@ -126,7 +126,7 @@ "@cypress/webpack-preprocessor": "5.4.1", "babel-plugin-istanbul": "6.0.0", "debug": "4.1.1", - "find-webpack": "1.10.0", + "find-webpack": "1.10.1", "mime-types": "2.1.26" }, "release": {