From 685f11e8c4012a6dd8de7a67cbc00c54da8c2612 Mon Sep 17 00:00:00 2001 From: vtereshyn Date: Sat, 16 Jan 2021 11:26:49 +0200 Subject: [PATCH] fix: webpack-preprocessor-lazy-load - React lazy load breaks webpack config fix: webpack-preprocessor-lazy-load - React lazy load breaks webpack config --- npm/webpack-preprocessor/index.ts | 1 + npm/webpack-preprocessor/test/unit/index.spec.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/npm/webpack-preprocessor/index.ts b/npm/webpack-preprocessor/index.ts index ccf236584ab9..0bf7f36f3638 100644 --- a/npm/webpack-preprocessor/index.ts +++ b/npm/webpack-preprocessor/index.ts @@ -198,6 +198,7 @@ const preprocessor: WebpackPreprocessor = (options: PreprocessorOptions = {}): F output: { path: path.dirname(outputPath), filename: path.basename(outputPath), + ...(options.webpackOptions?.output ?? {}), }, }) .tap((opts) => { diff --git a/npm/webpack-preprocessor/test/unit/index.spec.js b/npm/webpack-preprocessor/test/unit/index.spec.js index 278a32fd67ef..6052e3d93e06 100644 --- a/npm/webpack-preprocessor/test/unit/index.spec.js +++ b/npm/webpack-preprocessor/test/unit/index.spec.js @@ -151,6 +151,20 @@ describe('webpack preprocessor', function () { }) }) + it('adds output options when user output options are non-default', function () { + const options = { webpackOptions: { output: { publicPath: '/' } } } + + return this.run(options).then(() => { + expect(webpack).to.be.calledWithMatch({ + output: { + path: 'output', + filename: 'output.js', + publicPath: '/', + }, + }) + }) + }) + describe('devtool', function () { beforeEach((() => { sinon.stub(typescriptOverrides, 'overrideSourceMaps')