Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add webpack arg for customizing webpack config #1155

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
customizeConfig: (config) => config // default
}).then(({ code, map, assets }) => {
console.log(code);
// Assets is an object of asset file names to { source, permissions, symlinks }
Expand Down
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
customizeConfig = (config) => config
} = {}
) {
// v8 cache not supported for ES modules
Expand Down Expand Up @@ -252,7 +253,7 @@ function ncc (
}));
}

const compiler = webpack({
const compiler = webpack(customizeConfig({
entry,
cache: cache === false ? undefined : {
type: "filesystem",
Expand Down Expand Up @@ -383,7 +384,7 @@ function ncc (
},
},
plugins
});
}));
compiler.outputFileSystem = mfs;
if (!watch) {
return new Promise((resolve, reject) => {
Expand Down