Reactjs react Uncaught SyntaxError中的延迟加载:意外标记<;

Reactjs react Uncaught SyntaxError中的延迟加载:意外标记<;,reactjs,webpack,lazy-loading,code-splitting,Reactjs,Webpack,Lazy Loading,Code Splitting,我正在尝试在我的react应用程序中实现延迟加载和块分割。到目前为止,一切都运转良好,确实没有任何谷歌无法解决的问题,但这让我头痛不已。请在下面找到我的宝贝和网页配置设置 B.法律改革委员会 { "plugins": [ "@babel/plugin-syntax-dynamic-import", "@babel/plugin-transform-member-expression-literals", "@babel/plugin-transform-property-lite

我正在尝试在我的react应用程序中实现延迟加载和块分割。到目前为止,一切都运转良好,确实没有任何谷歌无法解决的问题,但这让我头痛不已。请在下面找到我的宝贝和网页配置设置

B.法律改革委员会

{
  "plugins": [
  "@babel/plugin-syntax-dynamic-import",
  "@babel/plugin-transform-member-expression-literals",
  "@babel/plugin-transform-property-literals",
  "@babel/plugin-proposal-object-rest-spread",
  "@babel/plugin-proposal-class-properties",
  "@babel/plugin-transform-runtime",
  "@babel/plugin-transform-regenerator"
 ],
 "presets": [
 [
  "@babel/preset-env",
   {
     "useBuiltIns": "usage"
   }
  ],
  "@babel/preset-react"
 ],
 "env": {
  "karma": {
   "plugins": [
    [
      "istanbul",
      {
        "exclude": [
          "tests/*.test.js"
        ]
      }
     ]
   ]
  }
 }
}
weback.config.js

`
 const developmentConfig = merge([
    {
      output: {
      chunkFilename: '[name].[chunkhash:4].js',
      filename: '[name].[chunkhash:4].js',
      path: PATHS.build,
    },
    optimization: {
      splitChunks: {
        cacheGroups: {
          commons: {
           test: NodeRegex,
           name: 'vendor',
           chunks: 'initial',
           minChunks: 2,
         },
       },
     },
    },
  },
  parts.loadCSS(),
  parts.loadImages(),
  parts.generateSourceMaps({ type: 'cheap-module-eval-source-map' }),
  parts.clean(PATHS.build), // deletes old dist folder
]);`

 module.exports = (mode) => {
  if (mode === 'production') {
   return merge(commonConfig, productionConfig, { mode });
  }
  return merge(commonConfig, developmentConfig, { mode });
 };

我终于解决了这个问题。问题在我的模板中。我设置了一条如下的公共路径:

<% var reactClentPath = '/react-client/dist'; %>
<script src="<%= reactClentPath %>/<%= htmlWebpackPlugin.files.chunks[key].entry %>" type="text/javascript"></script>

我所要做的就是去掉它,让webpack-config.js中设置的公共路径来处理这个问题。
由于某种原因,我将问题缩小到了HTMLwebpack插件,它似乎在dist文件夹后面注册了我的应用程序、运行时和供应商js文件。i、 e.“/dist/ap.js”。。。但不是动态导入。有人知道为什么会这样吗。