diff --git a/readme.md b/readme.md index 9bbc770f..2d5709d7 100644 --- a/readme.md +++ b/readme.md @@ -83,7 +83,11 @@ require('@zeit/ncc')('/path/to/input', { watch: false, // default v8cache: false, // default quiet: false, // default - debugLog = false // default + debugLog = false, // default + // https://webpack.js.org/configuration/resolve/#resolvealias + resolveAlias: {}, // default + // https://webpack.js.org/configuration/resolve/#resolvemodules + resolveModules: [] // 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 9c250b74..2dd8dad0 100644 --- a/src/index.js +++ b/src/index.js @@ -45,7 +45,9 @@ module.exports = ( v8cache = false, filterAssetBase = process.cwd(), quiet = false, - debugLog = false + debugLog = false, + resolveAlias = {}, + resolveModules = [] } = {} ) => { if (!quiet) { @@ -128,10 +130,12 @@ module.exports = ( libraryTarget: "commonjs2" }, resolve: { + alias: resolveAlias, extensions: SUPPORTED_EXTENSIONS, // webpack defaults to `module` and `main`, but that's // not really what node.js supports, so we reset it mainFields: ["main"], + modules: ['node_modules'].concat(resolveModules), plugins: resolvePlugins }, // https://github.com/zeit/ncc/pull/29#pullrequestreview-177152175