Skip to content

打包后,如何文件归类,及打包后ie报错 #76

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

Open
SungyWeb opened this issue Mar 4, 2019 · 5 comments
Open

打包后,如何文件归类,及打包后ie报错 #76

SungyWeb opened this issue Mar 4, 2019 · 5 comments
Labels
讨论 欢迎大家继续参与讨论,征集各方面的观点

Comments

@SungyWeb
Copy link

SungyWeb commented Mar 4, 2019

运行ng build --prod后(注意:下列问题都是打包后

    1. 文件都在项目根目录,可以js都放到一个js目录下么?
    1. 会有一些图片、css、字体文件也在项目的根目录,可以自动放到assets里么?
    1. 可以给assets里的文件加hash么?目前只有项目根目录下的文件自动加hash
    1. 放到服务器后,其他浏览器正常,ie 11浏览器无法正常显示,控制台报错:
      SCRIPT438: 对象不支持“fill”属性或方法
      vendor.6c9cf85ae50a464546d9.js (1,121979)
      感谢回答!!
@SungyWeb
Copy link
Author

SungyWeb commented Mar 4, 2019

版本信息

Angular CLI: 6.1.5
Node: 10.15.1
OS: win32 x64
Angular: 6.1.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.5
@angular-devkit/build-angular     0.7.5
@angular-devkit/build-optimizer   0.7.5
@angular-devkit/build-webpack     0.7.5
@angular-devkit/core              0.7.5
@angular-devkit/schematics        0.7.5
@angular/cli                      6.1.5
@ngtools/webpack                  6.1.5
@schematics/angular               0.7.5
@schematics/update                0.7.5
rxjs                              6.3.3
typescript                        2.7.2
webpack                           4.9.2

@wszgrcy
Copy link
Collaborator

wszgrcy commented Mar 4, 2019

提供可能的解决方案

  1. 可能是使用过高的语法了

使用core-js,直接把整个包导入,虽然不知道缺什么但是全导入方便以后写es6以上的语法
在polyfill.ts文件中导入

好像没2 了,先试试1行不行,不行再给你编一个

@SungyWeb
Copy link
Author

SungyWeb commented Mar 5, 2019

解决了问题4, 怪自己以前没有仔细看,里面有写ie需要的core-js,qqq,
还有个问题5 , 就是想用 prerenderSpaGlugin,但是不知道怎么暴露webpack的配置

@wszgrcy
Copy link
Collaborator

wszgrcy commented Mar 5, 2019

资源那个是配置angular.json,有相关的配置策略,glob匹配,input导入路径,output导出路径,如果你想要更详细的话找angular-cli的wiki里面有
一般情况下建议放src目录下,当然不放好像也无所谓(.....能跑就行)
webpack的抱歉,虽然我知道webpack 也知道angular,但是自己写angular的webpack解析文件还是.......太懒
毕竟,angular唯一的优点还是免配置了.可以自己配置,但是貌似这样的话就要从头到尾配置一遍

@asnowwolf
Copy link
Contributor

问题 iii 有过讨论,参见这个:angular/angular-cli#3415

目前还没有打算内置支持,不过已经重新纳入讨论了。

问题1、2 其实可以考虑自己写一个 postbuild 脚本,对它们进行处理,因为你需要修改的地方其实只有 dist/index.html 而已。相比 ngx-build-plugins 等方案,这种方案更简洁,也更少侵入性。

@asnowwolf asnowwolf added the 讨论 欢迎大家继续参与讨论,征集各方面的观点 label May 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
讨论 欢迎大家继续参与讨论,征集各方面的观点
Projects
None yet
Development

No branches or pull requests

3 participants