我在一个创建反应应用程序项目中将李娜添加到webpack配置中,因此最终的规则如下:
{
"test": /\.(js|mjs|jsx|ts|tsx)$/,
"include": "C:\\Project\\src",
"use": [
{
"loader": "C:\\Project\\node_modules\\babel-loader\\lib\\index.js",
"options": {
"customize": "C:\\Project\\node_modules\\babel-preset-react-app\\webpack-overrides.js",
"presets": [
[
"C:\\Project\\node_modules\\babel-preset-react-app\\index.js",
{ "runtime": "automatic" }
],
"C:\\Project\\node_modules\\@linaria\\babel-preset\\lib\\index.js"
],
"babelrc": false,
"configFile": false,
"cacheIdentifier": "production:babel-plugin-named-asset-import@0.3.7:babel-preset-react-app@10.0.0:react-dev-utils@11.0.4:react-scripts@4.0.3",
"plugins": [
[
"C:\\Project\\node_modules\\babel-plugin-named-asset-import\\index.js",
{
"loaderMap": {
"svg": {
"ReactComponent": "@svgr/webpack?-svgo,+titleProp,+ref![path]"
}
}
}
]
],
"cacheDirectory": true,
"cacheCompression": false,
"compact": true
}
},
{
"loader": "C:\\Project\\node_modules\\@linaria\\webpack-loader\\lib\\index.js",
"options": { "sourceMap": false, "cacheDirectory": "src/.linaria_cache" }
}
]
}但我得到的结果是:
目前还没有启用对实验性语法'jsx‘的支持
这个配置有什么问题吗?
发布于 2021-04-16 13:35:14
如果没有babelrc文件,@linaria\webpack-loader似乎无法工作(尽管预置已经在babel-加载程序上)。
{
"presets": [
"babel-preset-react-app",
"@linaria"
],
"plugins": [
[
"babel-plugin-named-asset-import",
{
"loaderMap": {
"svg": {
"ReactComponent": "@svgr/webpack?-svgo,+titleProp,+ref![path]"
}
}
}
],
"@babel/plugin-proposal-class-properties"
]
}https://stackoverflow.com/questions/67049954
复制相似问题