2

I've already installed jsx-html-class package via npm but i'm not sure how to modify my webpack.config.js file to make use of it.

var webpack = require("webpack");
var path = require("path");

module.exports = {
    context: path.join(__dirname, "src"),
    entry: "./js/index.js",
    module: { 
        loaders: [
            {
                test:/\.jsx?$/,
                exclude: "node_modules",
                loader: "babel-loader",
                query: {
                            presets:["react", "es2015", "stage-0"],
                            plugins:["transform-decorators-legacy", "jsx-html-class"]
                }
            }
     ]
    },
    output: {
        path: __dirname + "/src/",
        filename: "bundle.js"
    }
};
4
  • Don't you mean jsx-html-class ? npmjs.com/package/jsx-html-class . also.. do you really really need this? Just write className Commented Dec 13, 2016 at 21:26
  • my bad, i did mean jsx-html-class and that is actually the package i downloaded. I don't absolutely need it but would prefer to have it for easier readability and now i just wanna know how just for the sake of knowing. Commented Dec 13, 2016 at 21:56
  • What is the error you get when you try to run webpack? Commented Dec 13, 2016 at 23:21
  • If i inclue jsx-html-class in my plugins i get the error: Module build failed: TypeError: babel.Transformer is not a contstructor at module.exports (C:\Users\owner\Desktop\Reduxstagram\node_modules\jsx-html-class\index.js:2:10 if i remove jsx-html-class from the plugins i get the error: Warning: Unknown DOM property class. Did you mean className? or Commented Dec 13, 2016 at 23:32

1 Answer 1

2

I solved the same problem with this:

npm install --save-dev babel-plugin-react-html-attrs

then add this to your webpack config:

loaders: [{
    test: /\.js?$/,
    loader: 'babel-loader',
    query: {
        presets: ['react', 'es2015'],
        plugins: ['react-html-attrs']
    }
}]

or via .babelrc

{
  "plugins": [
    "react-html-attrs"
  ]
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.