Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pwacompat.min.js:1 Uncaught SyntaxError: Unexpected token < #3466

Closed
ffalconjs opened this issue Jan 24, 2019 · 10 comments
Closed

pwacompat.min.js:1 Uncaught SyntaxError: Unexpected token < #3466

ffalconjs opened this issue Jan 24, 2019 · 10 comments

Comments

@ffalconjs
Copy link

当需要将项目部署到非根目录时,在config.js增加如下配置
history: 'hash',
base: '/nScreen',
publicPath: '/nScreen/',
outputPath: './nScreen',

执行npm start
在浏览器控制台报错
pwacompat.min.js:1 Uncaught SyntaxError: Unexpected token <

@ffalconjs
Copy link
Author

查看生成的pwacompat.min.js 是一段html 而不是js

@chenshuai2144
Copy link
Collaborator

是因为没有生成 pwacompat.min.js ,这个 js 是你自己的吗?

@ffalconjs
Copy link
Author

pwacompat.min.js 这个文件antd pro原工程生成的 不修改部署路径是能够正常生成一段js,修改部署路径后才会出错。

@chenshuai2144
Copy link
Collaborator

看来是 pwa 生成的。参照
#3508 关掉 pwa 好了

@ffalconjs
Copy link
Author

关掉还是会生成pwa相关文件,自动生成的html文件中,还是引入了pwa
pwa: false,

@mathcw
Copy link

mathcw commented Mar 6, 2019

pwa:false 依然存在本问题

@jing-wu
Copy link

jing-wu commented Mar 24, 2019

经测试,pwa:false确实还是存在这个问题

@kuhami
Copy link

kuhami commented Apr 10, 2019

经测试,把 pwa设置成false,问题已解决!

我的这个问题出现原因:因为我在config.js 加了 publicPath: '',才导致的
解决办法:把 pwa设置成false,或者 再把 publicPath: '' 删掉
github地址:https://github.com/kuhami/react-ant

@kuhami
Copy link

kuhami commented Apr 10, 2019

当需要将项目部署到非根目录时,在config.js增加如下配置
history: 'hash',
base: '/nScreen',
publicPath: '/nScreen/',
outputPath: './nScreen',

执行npm start
在浏览器控制台报错
pwacompat.min.js:1 Uncaught SyntaxError: Unexpected token <

#ffalconjs 你把 publicPath: '/nScreen/', 删掉就ok了

@boyongjiong
Copy link

@jing-wu @ffalconjs @mathcw
我这边 ant-design-pro 版本为:2.2.1
将 defaultSettings.js 中 pwa 设置为 false 之后不起作用的原因是 config.js 文件中配置 pwa 的代码为如下

pwa: pwa
        ? {
            workboxPluginMode: 'InjectManifest',
            workboxOptions: {
              importWorkboxFrom: 'local',
            },
          }
        : {},

修改为:

pwa: pwa
        ? {
            workboxPluginMode: 'InjectManifest',
            workboxOptions: {
              importWorkboxFrom: 'local',
            },
          }
        : false,

即三目运算后面的配置为 false 而不是 空对象

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants