Allow the module loaded by the plugin in the Webpack configuration

The following example will only work if some-module is a Node module and will not work for modules loaded by the Webpack plugin.

How can I use my own Webpack ( enhanced-resolve ) logic to resolve module paths in config?

In my case, it was a bower-webpack-plugin , but I think it should work the same with any ResolverPlugin

 var BowerWebpackPlugin = require("bower-webpack-plugin"); module.exports = { ... module: { plugins: [new BowerWebpackPlugin()], loaders: [ { // this won't work test: require.resolve("some-bower-module") loader: "imports?this=>window" } ] }; 
+7
webpack
source share
1 answer

require.resolve inside webpack.config.js resolved by Node, not by the Webpack converter. You can use require("path").resolve("path/to/bower/module") to get the full path to your Bower module.

+1
source share

All Articles