From 40376d0aa6dd29098ac27289eb43eb18b52c2f2a Mon Sep 17 00:00:00 2001 From: John Hollow Date: Mon, 29 Jan 2024 00:16:32 -0600 Subject: [PATCH] add webpack arg for extending config --- readme.md | 3 ++- src/index.js | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 5068ac36..19baf0e4 100644 --- a/readme.md +++ b/readme.md @@ -127,7 +127,8 @@ require('@vercel/ncc')('/path/to/input', { target: 'es2015', // default v8cache: false, // default quiet: false, // default - debugLog: false // default + debugLog: false, // default + webpack: (config) => config // default }).then(({ code, map, assets }) => { console.log(code); // Assets is an object of asset file names to { source, permissions, symlinks } diff --git a/src/index.js b/src/index.js index 8ffa3022..4e696c2e 100644 --- a/src/index.js +++ b/src/index.js @@ -57,7 +57,8 @@ function ncc ( production = true, // webpack defaults to `module` and `main`, but that's // not really what node.js supports, so we reset it - mainFields = ['main'] + mainFields = ['main'], + webpack: extendWebpack = (config) => config } = {} ) { // v8 cache not supported for ES modules @@ -252,7 +253,7 @@ function ncc ( })); } - const compiler = webpack({ + const compiler = webpack(extendWebpack({ entry, cache: cache === false ? undefined : { type: "filesystem", @@ -383,7 +384,7 @@ function ncc ( }, }, plugins - }); + })); compiler.outputFileSystem = mfs; if (!watch) { return new Promise((resolve, reject) => {