Skip to content

Commit

Permalink
fix(WebpackConfigGenerator): make sure that the webpackConfig: true o…
Browse files Browse the repository at this point in the history
…ption correctly loads the webpack.config.js file
  • Loading branch information
Martin Neundorfer committed Apr 23, 2020
1 parent 49db7e8 commit 0ee86f0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Webpack/ConfigGeneration/WebpackConfigGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export class WebpackConfigGenerator {
* @param context
*/
public generateConfiguration(context: WorkerContext): Promise<WorkerContext> {

// Apply the configurators on the context object
return Promise.resolve(context)
.then(context => this.configuratorWrapper(Ids.BASE, context, new BaseConfigurator()))
Expand Down Expand Up @@ -172,7 +171,12 @@ export class WebpackConfigGenerator {
const customWebpackConfigPath = path.resolve(context.parentContext.sourcePath, (context.app.webpackConfig as string));
try {
const customWebpackConfig = require(customWebpackConfigPath);
if (typeof customWebpackConfig !== "function")
if (path.basename(customWebpackConfigPath) === "webpack.config.js") {
if (!isPlainObject(customWebpackConfig))
return Promise.reject(new Error("The default export of webpack.config.js has to be an object!"));
context.webpackConfig = merge(context.webpackConfig, customWebpackConfig);
return Promise.resolve(context);
} else if (typeof customWebpackConfig !== "function")
return Promise.reject(new Error("The custom webpack config has to be a function!"));
context.eventEmitter.unbindAll(AssetBuilderEventList.CUSTOM_WEBPACK_CONFIG_LOADING);
context.eventEmitter.bind(AssetBuilderEventList.CUSTOM_WEBPACK_CONFIG_LOADING, () => customWebpackConfig(context));
Expand Down

0 comments on commit 0ee86f0

Please sign in to comment.