首页 > 解决方案 > 运行 gzipped react 代码给出错误“Uncaught SyntaxError: Unexpected token '<”

问题描述

我在 create-react-app 模板上创建了一个应用程序,并在 package.json 的 script 标签下添加了这个命令。

"postbuild": "find ./build -type f \\( -name \\*.js -o -name \\*.css \\) -exec gzip {} \\;"

我可以看到在build/static/js中创建了 gzipped js 文件。

现在,当我尝试使用serve -s build运行我的构建代码时,Uncaught SyntaxError: Unexpected token '< 出现错误。

标签: reactjsperformancegzipcreate-react-app

解决方案


推荐阅读