【发布时间】:2016-12-13 20:27:37
【问题描述】:
我已经通过npm 安装了jsx-html-class 包,但我不确定如何修改我的 webpack.config.js 文件以使用它。
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"
}
};
【问题讨论】:
-
你不是说
jsx-html-class吗? npmjs.com/package/jsx-html-class 。还有..你真的真的需要这个吗?写className -
我的错,我的意思是
jsx-html-class,这实际上是我下载的包。我不是绝对需要它,但为了更容易阅读,我更愿意拥有它,现在我只想知道如何只是为了知道。 -
你尝试运行 webpack 时遇到什么错误?
-
如果我在我的
plugins中包含jsx-html-class,我会得到错误: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如果我从plugins中删除jsx-html-class,我会得到错误:Warning: Unknown DOM property class. Did you mean className?或