1.5.4 • Published 9 years ago
mimic-webpack v1.5.4
mimic-webpack
Mimics a webpack config's filename extensions, aliases, and loaders inside of the current node process.
You might want to mimic.install():
- instead of bundling your specs with webpack.
- before using linter rules like
eslint-plugin-require-path-exists. - when performing universal rendering with code you also plan to bundle with webpack.
installation
npm install mimic-webpackusage
In your entry file:
var Mimic = require('mimic-webpack');
new Mimic({
webpackConfig: { // pass your webpack config here
resolve: {
extensions: ['.foo'],
alias: {
myModule: 'theirModule'
}
},
module: {
loaders: [{
test: /\.foo$/,
loader: 'foo-loader'
}]
}
}
}).install();myModule.foo:
// code to be processed with foo-loaderNow, anywhere in your project, you can do this:
require('theirModule');In the above example:
theirModuleis aliased tomyModuledue toresolve.alias- The
.fooextension is inferred due to `resolve.extensions. - The module is processed with
foo-loaderbecause ofmodule.loaders
api
Mimic.prototype.install- configuresrequirein the current node process to behave according to the webpack config specified byoptions.webpackConfigpassed to the constructor. Returns the current instance.Mimic.prototype.uninstall- un-does whatMimic.prototype.installdid. Returns the current instance.Mimic.restore- restores configuration to the way it was before Mimic was required in.
known issues
Paths that were resolved using custom properties in require.extensions will continue to resolve the same even after Mimic.restore or Mimic.prototype.uninstall have been called.
myMimic.uninstall();
require.resolve('theirModule'); // still resolves to myModule.foo.current limitations
- Loaders must be specified in the webpack config. Loaders specified on the require path will not work
installanduninstallcan only be run once per instance.
1.5.4
9 years ago
1.5.3
10 years ago
1.5.2
10 years ago
1.5.1
10 years ago
1.5.0
10 years ago
1.4.0
10 years ago
1.3.2
10 years ago
1.3.1
10 years ago
1.3.0
10 years ago
1.2.6
10 years ago
1.2.4
10 years ago
1.2.3
10 years ago
1.2.2
10 years ago
1.2.1
10 years ago
1.1.1
10 years ago
1.1.0
10 years ago
1.0.1
10 years ago
1.0.0
10 years ago