Mimics a webpack config's filename extensions, aliases, and loaders inside of the current node process.
You might want to
npm install mimic-webpack
In your entry file:
var Mimic = ;webpackConfig: // pass your webpack config hereresolve:extensions: '.foo'alias:myModule: 'theirModule'module:loaders:test: /\.foo$/loader: 'foo-loader';
// code to be processed with foo-loader
Now, anywhere in your project, you can do this:
In the above example:
theirModuleis aliased to
.fooextension is inferred due to `resolve.extensions.
requirein the current node process to behave according to the webpack config specified by
options.webpackConfigpassed to the constructor. Returns the current instance.
Mimic.prototype.uninstall- un-does what
Mimic.prototype.installdid. Returns the current instance.
Mimic.restore- restores configuration to the way it was before Mimic was required in.
Paths that were resolved using custom properties in
require.extensions will continue to resolve the same even after
Mimic.prototype.uninstall have been called.
myMimic;require; // still resolves to myModule.foo.
uninstallcan only be run once per instance.