ionic3-ng4 learning experience--(aot packaging problem solution)

Aot packaging can effectively alleviate the lag of the app on the phone and improve performance.

ionic build --prod

I did a test,

The difference between the official quickSeed packaged using aot and not using aot is:

aot:

www :1097kb

apk:4330kb

 

non-aot:

www:1450kb

apk:12400kb

 

The general problems encountered in prod packaging are

1. Access to @env/enviroment variables cannot be accessed. Solution: Do not access env variables by referencing @env/enviroment, and access env variables by referencing the enviroment/enviroment.ts file

 

2. Refer to third-party style files or font icons, such as iconfont, the solution: import the iconfont.css file in index.html instead of importing it in app.scss or other files

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325825303&siteId=291194637