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

使用preload之后生成的html文件多出来静态资源的引入 #4474

Closed
haojieguangxin opened this issue Aug 21, 2019 · 2 comments · May be fixed by Matthelonianxl/vue-cli#11, carlosrojaso/vue-cli#34, carlosrojaso/vue-cli#36 or Matthelonianxl/vue-cli#17

Comments

@haojieguangxin
Copy link

haojieguangxin commented Aug 21, 2019

Version

3.8.0

Environment info

vue 2.0

Steps to reproduce

  1. 使用npm run build进行打包
  2. 观察生成的index.html文件

发现有重复的css被引入

<link href=/css/app.b4661067.css rel=preload as=style>
<link href=/css/app.b4661067.css rel=stylesheet>

What is expected?

有preload的文件,不要再重新引入一遍了

What is actually happening?

出现了两个同名的文件引入


这个是因为,在vue-cli-service中使用了html-webpack-plugin的时候已经有部分静态资源引入到了index.html,再执行@vue/preload-webpack-plugin的时候,又把html-webpack-plugin中处理过的静态资源又处理了一遍引入到了页面中。我怎么保留preload的那个标签,删除掉不带preload的标签

@sodatea
Copy link
Member

sodatea commented Aug 21, 2019

这两个标签效果是不一样的。

@sodatea sodatea closed this as completed Aug 21, 2019
@haojieguangxin
Copy link
Author

haojieguangxin commented Aug 22, 2019

这两个标签效果是不一样的。

谢谢你的回答,这个知识点我有所误解。提出这个问题主要是因为使用lighthouse的时候提示了性能提升建议Preload key requests,就去查看了生成的index.html,误以为是因为两个同时存在导致的问题,现在回头去仔细看了一下优化建议,好像不是这个文件的问题。我会继续看下具体原因,再次感谢。而且可能不能从lighthouse中看单页应用的性能,还是需要更多成长和进步,谢谢 @sodatea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment