最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why Ionic 2 builds are so large, even for smallblank apps? - Stack Overflow

programmeradmin3浏览0评论

So I'm new to Ionic, and might be missing something. But I started a new blank app like so:

ionic start BlankApp --v2 blank

then added a browser platform:

cordova platform add browser

and then built for production:

ionic build browser

The output looks like this:

> 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 mand: cmd "/s /c "C:\Work\ionic\BlankApp\platforms\browser\cordova\build.bat""


Cleaning Browser project

I was expecting a small js bundle given that this app has nothing in it. Tree-shaking was supposed to have dropped a lot of code and the app was supposed, I think, but be lightening fast.

Unfortunately, that's not what happened.

The platforms/browser/www/build/js directory has a main.js file that is over 4MBs in size. There is also a main.css file with 500Kb of content.

What am I missing? am I looking in the wrong spot?

**UPDATE: ** My issue is that I'm trying to build a progressive web app. If I only wanted to build a mobile app, that'd be fine. But for a web app to download 4MB of stuff before even counting it's own content is crazy, I can't believe that is the state of the union on an RC4 release.

Thank you,

Eduardo

So I'm new to Ionic, and might be missing something. But I started a new blank app like so:

ionic start BlankApp --v2 blank

then added a browser platform:

cordova platform add browser

and then built for production:

ionic build browser

The output looks like this:

> 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 mand: cmd "/s /c "C:\Work\ionic\BlankApp\platforms\browser\cordova\build.bat""


Cleaning Browser project

I was expecting a small js bundle given that this app has nothing in it. Tree-shaking was supposed to have dropped a lot of code and the app was supposed, I think, but be lightening fast.

Unfortunately, that's not what happened.

The platforms/browser/www/build/js directory has a main.js file that is over 4MBs in size. There is also a main.css file with 500Kb of content.

What am I missing? am I looking in the wrong spot?

**UPDATE: ** My issue is that I'm trying to build a progressive web app. If I only wanted to build a mobile app, that'd be fine. But for a web app to download 4MB of stuff before even counting it's own content is crazy, I can't believe that is the state of the union on an RC4 release.

Thank you,

Eduardo

Share Improve this question edited Jan 10, 2017 at 3:32 Edy Bourne asked Jan 10, 2017 at 0:01 Edy BourneEdy Bourne 6,20616 gold badges61 silver badges114 bronze badges 2
  • If you're making a web app, you should probably just code it in pure HTMJ+JS+CSS, instead of using ionic. It'll save you a lot of space, and probably a lot of trouble. I don't think Ionic or Cordova were meant for that at all. – Ethan McTague Commented Jan 10, 2017 at 5:49
  • I was hoping to have one codebase and be able to wrap that web app as native apps as well. Ionic has support for Progressive Web Apps as one of its flagship features, therefore my question. Something must be off... – Edy Bourne Commented Jan 10, 2017 at 21:58
Add a ment  | 

2 Answers 2

Reset to default 7

use ionic build browser --prod

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. :)

发布评论

评论列表(0)

  1. 暂无评论