Skip to content

"You may need an appropriate loader to handle this file type..." for .jsx files  #94

Open
@HusnuAkcak

Description

@HusnuAkcak

When I install and compile I am getting this webpack error, what shoul I do?
I also tried the suggestions in this link, https://github.com/babel/babel-loader/issues/173

ERROR in ./node_modules/react-pivot/index.jsx 124:6
Module parse failed: Unexpected token (124:6)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| 
|     var html = (
>       <div className='reactPivot'>
| 
|       { this.props.hideDimensionFilter ? '' :

my webpack.config.json file as follows

const path = require("path");
const fs = require("fs");
const CopyPlugin  = require("copy-webpack-plugin");

// Webpack entry points. Mapping from resulting bundle name to the source file entry.
const entries = {};

// Loop through subfolders in the "TimeSheet" folder and add an entry for each one
const timeSheetDir = path.join(__dirname, "src/TimeSheet");
fs.readdirSync(timeSheetDir).filter(dir => {
    if (fs.statSync(path.join(timeSheetDir, dir)).isDirectory()) {
        entries[dir] = "./" + path.relative(process.cwd(), path.join(timeSheetDir, dir, dir));
    }
});

module.exports = {
    entry: entries,
    output: {
        filename: "[name]/[name].js"
    },
    resolve: {
        extensions: [".ts", ".tsx", ".js", ".jsx"],
        alias: {
            "vss-web-extension-sdk": path.resolve("node_modules/vss-web-extension-sdk")
        },
    },
    stats: {
        warnings: false
    },
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                loader: "ts-loader"
            },
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                loaders: ['react-hot', 'babel-loader?presets[]=react,presets[]=es2015']
            },
            {
                test: /\.scss$/,
                use: ["style-loader", "css-loader", "azure-devops-ui/buildScripts/css-variables-loader", "sass-loader"]
            },
            {
                test: /\.css$/,
                use: ["style-loader", "css-loader"],
            },
            {
                test: /\.woff$/,
                use: [{
                    loader: 'base64-inline-loader'
                }]
            },
            {
                test: /\.html$/,
                loader: "file-loader"
            }
        ],
    },
    plugins: [
        new CopyPlugin ({
            patterns: [{ from: "**/*.html", context: "src/TimeSheet" }]
        })
    ]
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions