我的反应应用中有以下反应代码,由webpack / babel传播:
import React from 'react';
import ReactDOM from 'react-dom';
class world extends React.Component {
render() {
return <h1>World</h1>
}
}
ReactDOM.render(<world/>, document.getElementById('js-app'));
然而,结果并非我的预期,它只会呈现:
<world data-reactroot></world>
这是我的webpack.config文件:
var path = require("path"),
webpack = require("webpack"),
watchBabel = require("watch-babel"),
srcJsDir = "assets/js/custom/",
srcCssDir = "assets/sass/",
srcDestJsDir = "assets/js/transpiled/",
options = { glob: "src/*.js" },
optionsCss = { glob: "src/*.scss" };
module.exports = {
entry: ["./assets/js/custom/app.js"],
output: {
path: "./assets/js/transpiled/",
filename: "app.es6c.js"
},
watch: true,
devServer: {
inline: true,
port: 8000
},
module: {
loaders: [{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: ['babel-loader'],
query: {
presets: ["react", "es2015", "stage-0"]
}
}]
},
resolveLoader: {
root: path.join(__dirname, 'node_modules/')
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify("production")
}
})
]
};
你能告诉我哪里出错吗?提前谢谢。