[英]Migrate from webpack v1 to v2 with webpack-cli produces error for tsx
I get this error when running build after migration, and not sure if it can't recognise tsx files or something inside of tsx file that it doesn't like: 我在迁移后运行build时遇到此错误,并且不确定它是否无法识别tsx文件或tsx文件中不喜欢的内容:
Failed to compile. 编译失败。 Error in ./src/index_app.tsx Module parse failed: /src/index_app.tsx Unexpected token (17:26) You may need an appropriate loader to handle this file type. ./src/index_app.tsx中的错误模块解析失败:/src/index_app.tsx意外的令牌(17:26)您可能需要一个适当的加载器来处理此文件类型。 SyntaxError: Unexpected token (17:26) @ multi main SyntaxError:意外的令牌(17:26)@ multi main
Content of index_app.tsx: index_app.tsx的内容:
17:const rootReducer = (state:any, action:any) => {
18: if (action.type === Actions.RESET_GLOBAL_STATE) {
19: state = undefined;
20: }
21: return reducers(state, action)
22:}
My webpack config after migration script: 迁移脚本后我的webpack配置:
not sure if it can't recognise tsx files or something inside of tsx file that it doesn't like 不确定它是否无法识别tsx文件或tsx文件中不喜欢的内容
Doesn't recognize tsx. 不承认tsx。
I would change 我会改变
{
test: /\.(ts|tsx)$/,
include: paths.appSrc,
use: [{
loader: 'ts-loader'
}],
}
To standard docs : https://webpack.js.org/guides/webpack-and-typescript/ 标准文档: https : //webpack.js.org/guides/webpack-and-typescript/
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: [ 'ts-loader' ]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.