FormidableLabs / webpack-dashboard

A CLI dashboard for webpack dev server
MIT License
13.87k stars 363 forks source link

webpack v5 with express: compiler.apply is not a function #312

Closed mmaday closed 3 years ago

mmaday commented 4 years ago

Please provide a description of the bug / issue, and provide the details below:

====================================================================

If the issue is visual, please provide screenshots here

When using webpack-dashboard with webpack version 5 and express, the following error occurs:

TypeError: compiler.apply is not a function

This can be resolved by adding the Dashboard plugin to the plugins section of the webpack config.

====================================================================

Steps to reproduce the problem

Follow the express instructions:

// Import the plugin:
var DashboardPlugin = require("webpack-dashboard/plugin");

// If you are using an express based dev server, add it with compiler.apply
compiler.apply(new DashboardPlugin());

====================================================================

Please provide a gist of relevant files
  1. package.json (specifically the script you are using to start the dashboard)
  2. webpack.config.js
  3. index.js (Your express based dev server, if applicable)

====================================================================

More Details

There are some vague mentions of this at https://webpack.js.org/migrate/5/#cleanup-the-build-code.

ryan-roemer commented 3 years ago

Hi @mmaday ! Can you see if the instructions in https://webpack.js.org/guides/development/#using-webpack-dev-middleware get you to a workable solution in your express set up? I'm rewriting the docs to point to this resource and recommend using a straight configuration file in all scenarios (as webpack now recommends). Thanks!