我真的很想使用reacts模板/组件来创建静态站点生成器。杰基尔和中间人必须被黑才能让这个..。
但是我发现了http://www.metalsmith.io的插件:https://github.com/yeojz/metalsmith-react-templates
到目前为止,我一直在跟踪:
var Metalsmith = require('metalsmith');
var reactTemplate = require('metalsmith-react-templates');
Metalsmith(__dirname)
.clean(true)
.use(reactTemplate({
directory: 'templates',
isStatic: true
}))
.source('src')
.destination('build')
.build(function(err) {
if (err) throw err;
});和jsx文件:
var React = require('react');
var Entry = React.createClass({
render: function() {
return ();
}
});
module.exports = Entry;当我运行节点build.js时,会出错:
entry.jsx: Unexpected token

金属匠-反应-模板的例子似乎是过时的,因此问题?
尝试过的建议@:
4 | render: function() {
5 |
> 6 | return (<p>Entry</p>);
| ^
7 | }
8 | });
9 | 发布于 2016-02-22 15:06:30
@salivan
如果即使在执行return (<p>Entry</p>);之后仍然存在问题,那么很有可能这实际上是babel编译器的问题。
您使用的是什么版本的babel?
如果是版本6或更高版本,请检查是否至少安装了babel-preset-react和babel-preset-es2015插件。
https://stackoverflow.com/questions/35536508
复制相似问题