Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
HusnuAkcak opened this issue Jul 27, 2020 · 3 comments

Comments

@HusnuAkcak
Copy link

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" }]
        })
    ]
};
@abdhalees
Copy link
Contributor

add this to your webpack config

  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        include: [
          path.join(__dirname, './app'),
          path.join(__dirname, './node_modules', 'react-pivot')
        ],
        use: babelLoader
      },
  ]
}

@ledsoft
Copy link

ledsoft commented Mar 21, 2021

Hi, I created a fork of this project and modified it to be compatible with Webpack. You can give it a try at https://github.com/ledsoft/react-pivot-webpack.

@dianrp22
Copy link

i cant use this library same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants