Debugging Webpack

This has caused me several days of exciting times… some of the errors Webpack gives can be a little misleading, showing one error when there’s in-fact a totally different underlying issue which will fix everything!

The following shows you everything you need;

<./node_modules/.bin/encore (or your command here> --watch --progress --display-error-details --verbose

You’ll need to replace the start of this command with something relevant to you, depending on the location of your encore / webpack executable.

Webpack Encore & CometD

This drove me nuts for hours;

These dependencies were not found:
* org/cometd in ./node_modules/cometd-jquery/jquery/jquery.cometd.js

The solution … in your webpack.config.js file;

config = Encore.getWebpackConfig();
config.resolve.alias["org/cometd"] = path.resolve(__dirname, "./node_modules/cometd-jquery/org/cometd");
config.resolve.alias["jquery.cometd"] = path.resolve(__dirname, "./node_modules/cometd-jquery/jquery/jquery.cometd");

// export the final configuration
module.exports = config;

After that you should be all good to go!

If you get an error about the ‘path’ function not existing, then just include the following at the top of the file;

var path = require('path');