score:42

Accepted answer

You are using unnecessary escape character: which is not required.

Replace test: '/\.(js|jsx)$/', with test: /\.js$|jsx/, it should work fine.

I replicated your issue in my machine and found the same which is resolved by the above fix.

hope this helps, happy coding!!!

score:-2

add a .babelrc file to the same folder where your node_modules folder is, with the below content

{
  "presets": ["@babel/preset-react"]
}

score:-2

Put the code mentioned below in webpack file

mix.extend(
    "graphql",
    new (class {
        dependencies() {
            return ["graphql", "graphql-tag"];
        }

        webpackRules() {
            return {
                test: /\.(graphql|gql)$/,
                exclude: /node_modules/,
                loader: "graphql-tag/loader"
            };
        }
    })()
);


mix.js("resources/js/app.js", "public/js").vue();

mix.graphql();

score:1

This error happened to me simply because the file was placed in the parent folder of the project (i.e. outside the project's folder).

Moving the file to the appropriate folder fixed it.

score:14

The selected answer missing some details:

It should be test: /\.js|\.jsx$/

\: is an escape character in this case for .

|: is an Alternation / OR operand

$: is end of line

Hopefully this is useful for you.

Source: https://www.rexegg.com/regex-quickstart.html


Related Query

More Query from same tag