我有像这样的文件调用abc.jsx
var MyTitle = require('./MyTitle')
but I have to do require('./MyTitle)
因为我运行webpack它给我错误。
ERROR in ./js/MyTitle.jsx
Module not found: Error: Cannot resolve 'file' or 'directory' ./MyTitle in /Users/username/Documents/intro-to-react/js
@ ./js/MyTitle.jsx 5:14-34
答案 0 :(得分:0)
您应该设置webpack配置以使用babel-loader解析jsx文件。模块加载器中的以下行@Bean
public MappedInterceptor myInterceptor()
{
return new MappedInterceptor(null, new MyInterceptor());
}
告诉webpack解析test: /\.js?$/,
和.js
文件类型。
.jsx