Skip to content

import/no-webpack-loader-syntax rule inappropriate if Webpack config can't be ejected #11983

@Josh-Cena

Description

@Josh-Cena

Is your proposal related to a problem?

If I want to configure an alternative loader for a file, it's quite frustrating if (1) we can't eject and (2) we can't use inline loaders.

I was helping someone to render Markdown in CRA. In order to do so, we obviously have to get around the default file-loader for MD files so we could get the content into the React code. To start with something simple, I recommended raw-loader. With my limited experience with CRA, there's no way to customize Webpack loaders unless I eject, so I recommended them to use inline !!raw-loader!. However, this led to the import/no-webpack-loader-syntax error, which I have to spend another five minutes explaining what ESLint does and how this rule can be gotten around.

Describe the solution you'd like

I understand that CRA is a very, very opinionated tool and promotes "good practices", but this rule just gets in the way as soon as we want to do something fancier. How many people who use inline loaders don't know what they are doing and don't know the alternative—using webpack.config.js?

Describe alternatives you've considered

Expose a webpack.config.js file that's merged with the default config? From the projects I've ejected, doesn't seem like it's currently the case. #8869 has been open with no responses for almost two years now.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions