Skip to content

I may have a fix for "support for webpack v5" #1740

Closed
@wh1t3h47

Description

@wh1t3h47

I am opening this issue because the original one was flagged as spam and I coudn't comment on it
#1703

I was able to solve this problem as described:
1 - Eject your project;
2 - Fix webpack configuration to port to webpack v5; how to do it?

There is also a comment which says something like TODO remove in webpack 5, remove the line below;

3 - Search for formatWebpackMessages(webpackMessages) inside config/build.js;
4 - Replace with the following block of code:

        const webpackMessages = stats.toJson({
          all: false,
          warnings: true,
          errors: true,
        });
        webpackMessages.errors = webpackMessages.errors.map(
          /** @param {object|string} error either from webpack 4 or 5 */
          (error) => (typeof error === 'string')? error: (error.message || ''),
        );
        messages = formatWebpackMessages(webpackMessages);
      }

I hope this helps.

EDIT:
Since we have to support webpack v4 and v5, I made the above code detect if the error object is from webpack 4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions