为什么Ionic 2版本如此之大,即使对于小/空白的应用程序也是如此?

时间:2017-01-10 00:01:42

标签: javascript cordova browser build ionic2

所以我是Ionic的新手,可能会遗漏一些东西。但我开始这样一个新的空白应用程序:

ionic start BlankApp --v2 blank

然后添加了一个浏览器平台:

cordova platform add browser

然后为生产而建造:

ionic build browser

输出如下:

> ionic-hello-world@ ionic:build C:\Work\ionic\BlankApp
> ionic-app-scripts build

keywords if/then/else require v5 option
[17:56:25]  ionic-app-scripts 0.0.47
[17:56:25]  build dev started ...
[17:56:25]  clean started ...
[17:56:25]  clean finished in 3 ms
[17:56:25]  copy started ...
[17:56:25]  transpile started ...
[17:56:28]  transpile finished in 3.47 s
[17:56:28]  webpack started ...
[17:56:28]  copy finished in 3.65 s
[17:56:34]  webpack finished in 5.65 s
[17:56:34]  sass started ...
[17:56:35]  sass finished in 1.45 s
[17:56:35]  build dev finished in 10.73 s

You have been opted out of telemetry. To change this, run: cordova telemetry on.

Error loading cordova-browser


Running command: cmd "/s /c "C:\Work\ionic\BlankApp\platforms\browser\cordova\build.bat""


Cleaning Browser project

我期待一个小js包,因为这个应用程序没有任何内容。树震动应该已经丢掉了很多代码,而我认为该应用程序应该被认为是快速闪亮。

不幸的是,事情并非如此。

platforms/browser/www/build/js目录的main.js文件大小超过4MB。还有一个包含500Kb内容的main.css文件。

我错过了什么?我在找错了地方吗?

**更新:**我的问题是我正在尝试构建一个渐进的Web应用程序。如果我只想构建一个移动应用程序,那就没事了。但是对于一个网络应用程序来下载4MB的东西,甚至算上它自己的内容是疯了,我不敢相信这是RC4版本的联盟状态。

谢谢,

爱德华

2 个答案:

答案 0 :(得分:7)

使用离子构建浏览器--prod

答案 1 :(得分:1)

When you think a bit about it, it's quite logic that your build is large. It's because, inside the build, there is Cordova and all its dependencies and plugins. But when you see that main.js and main.css are quite large, it's because of Cordova who's trying to put every library, plugins, etc... in the same file.

But, could you upload those 2 files, just to see if I'm right. :)