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')