enhanced-resolve
Features
Getting Started
Install
# npm
npm install enhanced-resolve
# or Yarn
yarn add enhanced-resolveCreating a Resolver
const {
NodeJsInputFileSystem,
CachedInputFileSystem,
ResolverFactory
} = require('enhanced-resolve');
// create a resolver
const myResolver = ResolverFactory.createResolver({
// Typical usage will consume the `NodeJsInputFileSystem` + `CachedInputFileSystem`, which wraps the Node.js `fs` wrapper to add resilience + caching.
fileSystem: new CachedInputFileSystem(new NodeJsInputFileSystem(), 4000),
extensions: ['.js', '.json']
/* any other resolver options here. Options/defaults can be seen below */
});
// resolve a file with the new resolver
const context = {};
const resolveContext = {};
const lookupStartPath = '/Users/webpack/some/root/dir';
const request = './path/to-look-up.js';
myResolver.resolve({}, lookupStartPath, request, resolveContext, (err/*Error*/, filepath/*string*/) => {
// Do something with the path
});Resolver Options
Field
Default
Description
Plugins
Plugin Boilerplate
Tests
Passing options from webpack
License
Last updated
