ionic-team / ionic-app-scripts

App Build Scripts for Ionic Projects
http://ionicframework.com/
MIT License
608 stars 304 forks source link

ionic build android --prod does not generate main.js, main.js.map and main.css #577

Closed chunhoong closed 7 years ago

chunhoong commented 7 years ago

Note: for support questions, please use one of these channels:

https://forum.ionicframework.com/ http://ionicworldwide.herokuapp.com/

Short description of the problem:

main.js, main.js.map and main.css are not generated when --prod is used during build. Tested with --aot as well, so it should be related to only AoT. "ionic build android" is working fine though.

I am trying with fresh vanilla ionic project, and it is working well. I am not sure if it is related to my cordova version, as I am using cordova from IBM MobileFirst Platform 7.1 instead of conventional cordova.

What behavior are you expecting?

main.js, main.js.map and main.css should be generated.

Steps to reproduce:

  1. "ionic build android --prod" or "ionic build android --aot"
insert any relevant code between the above and below backticks

Which @ionic/app-scripts version are you using? 0.0.47

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

Chrome debugger message image

vintage commented 7 years ago

I have same issue with one of my projects.

npm run ionic:build --aot --verbose

npm run ionic:build --aot --verbose
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/Cellar/node/6.4.0/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'run',
npm verb cli   'ionic:build',
npm verb cli   '--aot',
npm verb cli   '--verbose' ]
npm info using npm@3.10.6
npm info using node@v6.4.0
npm verb run-script [ 'preionic:build', 'ionic:build', 'postionic:build' ]
npm info lifecycle moba_quiz@2.0.0~preionic:build: moba_quiz@2.0.0
npm info lifecycle moba_quiz@2.0.0~ionic:build: moba_quiz@2.0.0

> moba_quiz@2.0.0 ionic:build /Users/krykowski/workspace/moba_quiz
> ionic-app-scripts build

[10:59:09]  ionic-app-scripts 0.0.47
[10:59:09]  build dev started ...
[10:59:09]  clean started ...
[10:59:09]  clean finished in 6 ms
[10:59:09]  copy started ...
[10:59:09]  ngc started ...
[10:59:21]  ngc finished in 11.98 s
[10:59:21]  webpack started ...
[10:59:22]  copy finished in 13.18 s
npm verb lifecycle moba_quiz@2.0.0~ionic:build: unsafe-perm in lifecycle true
npm verb lifecycle moba_quiz@2.0.0~ionic:build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/krykowski/workspace/moba_quiz/node_modules/.bin:/usr/local/Cellar/node/6.4.0/bin:/Users/krykowski/workspace/moba_quiz/parsers/bin:/opt/local/bin:/opt/local/sbin:/usr/local/lib/dnx/runtimes/dnx-coreclr-darwin-x64.1.0.0-rc1-update1/bin:/Users/krykowski/.dnx/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/krykowski/Library/Android/sdk/platform-tools:/Users/krykowski/Library/Android/sdk/tools:/Users/krykowski/Library/Android/sdk/platform-tools:/Users/krykowski/Library/Android/sdk/build-tools/25.0.0
npm verb lifecycle moba_quiz@2.0.0~ionic:build: CWD: /Users/krykowski/workspace/moba_quiz
npm info lifecycle moba_quiz@2.0.0~postionic:build: moba_quiz@2.0.0
npm verb exit [ 0, true ]
npm info ok

Then the www/build/ dir contains only polyfills.js. The output of other project which builds properly looks like this:

npm info it worked if it ends with ok
npm verb cli [ '/usr/local/Cellar/node/6.4.0/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'run',
npm verb cli   'ionic:build',
npm verb cli   '--aot',
npm verb cli   '--verbose' ]
npm info using npm@3.10.6
npm info using node@v6.4.0
npm verb run-script [ 'preionic:build', 'ionic:build', 'postionic:build' ]
npm info lifecycle zgadula@~preionic:build: zgadula@
npm info lifecycle zgadula@~ionic:build: zgadula@

> zgadula@ ionic:build /Users/krykowski/workspace/party_game
> ionic-app-scripts build

[11:01:09]  ionic-app-scripts 0.0.47
[11:01:09]  build dev started ...
[11:01:09]  clean started ...
[11:01:09]  clean finished in 2 ms
[11:01:09]  copy started ...
[11:01:09]  ngc started ...
[11:01:18]  ngc finished in 9.41 s
[11:01:18]  webpack started ...
[11:01:19]  copy finished in 10.46 s
[11:01:33]  webpack finished in 15.26 s
[11:01:33]  sass started ...
[11:01:35]  sass finished in 1.84 s
[11:01:35]  build dev finished in 26.54 s
npm verb lifecycle zgadula@~ionic:build: unsafe-perm in lifecycle true
npm verb lifecycle zgadula@~ionic:build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/krykowski/workspace/party_game/node_modules/.bin:/usr/local/Cellar/node/6.4.0/bin:/Users/krykowski/workspace/moba_quiz/parsers/bin:/opt/local/bin:/opt/local/sbin:/usr/local/lib/dnx/runtimes/dnx-coreclr-darwin-x64.1.0.0-rc1-update1/bin:/Users/krykowski/.dnx/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/krykowski/Library/Android/sdk/platform-tools:/Users/krykowski/Library/Android/sdk/tools:/Users/krykowski/Library/Android/sdk/platform-tools:/Users/krykowski/Library/Android/sdk/build-tools/25.0.0
npm verb lifecycle zgadula@~ionic:build: CWD: /Users/krykowski/workspace/party_game
npm info lifecycle zgadula@~postionic:build: zgadula@
npm verb exit [ 0, true ]
npm info ok

I have no idea what's wrong with the first project (it's much bigger) as they use same version of the ionic/cli/app-scripts etc. Any ideas?

chunhoong commented 7 years ago

@vintage may I know what cordova version are you using?

vintage commented 7 years ago

@rephchunhoong

Here's my ionic info & ionic platform list:

Your system information:

Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.17
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.47
ios-deploy version: 1.9.0
ios-sim version: 5.0.6
OS: macOS Sierra
Node Version: v6.4.0
Xcode version: Xcode 8.1 Build version 8B62
Installed platforms:
  android 6.1.0
  ios 4.3.1
Available platforms:
  amazon-fireos ~3.6.3 (deprecated)
  blackberry10 ~3.8.0
  browser ~4.1.0
  firefoxos ~3.6.3
  osx ~4.0.1
  webos ~3.7.0

Both apps gives the same output.

vintage commented 7 years ago

I'm also including installed dependencies, maybe it's some problem with any of them? Still debugging, but didn't find anything interesting yet.

npm dependencies from non-working app:

npm ls --depth=0
moba_quiz@2.0.0 /Users/krykowski/workspace/moba_quiz
├── @angular/common@2.2.1
├── @angular/compiler@2.2.1
├── @angular/compiler-cli@2.2.1
├── @angular/core@2.2.1
├── @angular/forms@2.2.1
├── @angular/http@2.2.1
├── @angular/platform-browser@2.2.1
├── @angular/platform-browser-dynamic@2.2.1
├── @angular/platform-server@2.2.1
├── @ionic/app-scripts@0.0.47
├── @ionic/storage@1.1.6
├── @types/lodash@4.14.37
├── crypto-js@3.1.8
├── ionic-angular@2.0.0-rc.4
├── ionic-native@2.2.11
├── ionicons@3.0.0
├── lodash@4.16.1
├── ng2-translate@3.1.2
├── raven-js@3.7.0
├── rxjs@5.0.0-beta.12
├── typescript@2.0.9
└── zone.js@0.6.26

npm dependencies from working app:

npm ls --depth=0

zgadula@ /Users/krykowski/workspace/party_game
├── @angular/common@2.2.1
├── @angular/compiler@2.2.1
├── @angular/compiler-cli@2.2.1
├── @angular/core@2.2.1
├── @angular/forms@2.2.1
├── @angular/http@2.2.1
├── @angular/platform-browser@2.2.1
├── @angular/platform-browser-dynamic@2.2.1
├── @angular/platform-server@2.2.1
├── @ionic/app-scripts@0.0.47
├── @ionic/storage@1.1.6
├── @types/lodash@4.14.37
├── ionic-angular@2.0.0-rc.4
├── ionic-native@2.2.11
├── ionicons@3.0.0
├── lodash@4.16.1
├── rxjs@5.0.0-beta.12
├── typescript@2.0.9
└── zone.js@0.6.26
chunhoong commented 7 years ago

Hi @vintage,

I see you are using ng2-translate too. Is there any chance it breaks the thing?

-ChunHoong-

vintage commented 7 years ago

@rephchunhoong I'll try later this today (or tomorrow morning) add ng2-translate to my working app and see if it breaks the build process. Will ping you when got further details.

NoNameProvided commented 7 years ago

I see you are using ng2-translate too. Is there any chance it breaks the thing?

We don't use ng2-translate, but we also face this issue. serve works for development but we cannot build or serve with the --prod or --aot flag.

vintage commented 7 years ago

Thanks for letting us know, then it have to be something else. I just don't understand one thing - look at this output:

[10:59:21]  webpack started ...
[10:59:22]  copy finished in 13.18 s
npm verb lifecycle moba_quiz@2.0.0~ionic:build: unsafe-perm in lifecycle true

It doesn't print that webpack finished, so why is that? It seems that process has been aborted somehow, but there is no exception message anywhere about it (and overall build finish with "ok"). Can you confirm it works same for you guys @rephchunhoong @NoNameProvided ?

NoNameProvided commented 7 years ago

@vintage for us webpack finishes, below is the output of ionic serve --prod --verbose

Console output ``` Task: title=serve, name=serve, summary=Start a local development server for app dev/testing, [options]=, title=Print app console logs to Ionic CLI, boolean=true, title=Print dev server logs to Ionic CLI, boolean=true, --port|-p=Dev server HTTP port (8100 default), --livereload-port|-r=Live Reload port (35729 default), title=Disable launching a browser, boolean=true, title=Do not start live reload, boolean=true, title=Do not add proxies, boolean=true, --address=Use specific address or return with failure, title=Have the server listen on all addresses (0.0.0.0), boolean=true, --browser|-w=Specifies the browser to use (safari, firefox, chrome), --browseroption|-o=Specifies a path to open to (/#/tab/dash), title=Test your apps on multiple screen sizes and platform types, boolean=true, title=Disable running gulp during serve, boolean=true, --platform|-t=Start serve with a specific platform (ios/android), isProjectTask=true, run=function run(ionic, argv, rawCliArguments) { // Support `ionic lab` as a shortcut for `ionic serve --lab` var runsLab = rawCliArguments[0] == 'lab'; if (runsLab) { rawCliArguments.push('--lab'); } /** * Before running the internal server check to see if npmscripts has * a ionic specific serve command. If so then run it instead. */ return npmScripts.hasIonicScript('serve') .then(function(hasServeCommand) { if (hasServeCommand) { return npmScripts.runIonicScript('serve', rawCliArguments.slice(1)); } else { return runServer(argv); } }) .catch(function(error) { log.error('There was an error serving your Ionic application:', error); }); } Looking up Ionic root, cwd: /Users/attila/budacode/transfermarkt-mobile Ionic root directory: /Users/attila/budacode/transfermarkt-mobile Package.json found scripts: test=bnr test, test:watch=bnr test --auto-watch --no-single-run, pretest:watch=node karma-watch.js &, start=node ./config/bootstrap.js && ionic serve, build=node ./config/bootstrap.js && ionic-app-scripts build --prod, ionic:serve=ionic-app-scripts serve, ionic:build=npm run build, ionic:emulate=npm run build, ionic:deploy=npm run build, ionic:run=npm run build, pr=hub pull-request -b develop Npm scripts: test=bnr test, test:watch=bnr test --auto-watch --no-single-run, pretest:watch=node karma-watch.js &, start=node ./config/bootstrap.js && ionic serve, build=node ./config/bootstrap.js && ionic-app-scripts build --prod, ionic:serve=ionic-app-scripts serve, ionic:build=npm run build, ionic:emulate=npm run build, ionic:deploy=npm run build, ionic:run=npm run build, pr=hub pull-request -b develop Gulpfile found: false > transfermarkt-mobile@ ionic:serve /Users/attila/budacode/transfermarkt-mobile > ionic-app-scripts serve "--prod" "--verbose" [17:24:51] ionic-app-scripts 0.0.47 [17:24:52] watch started ... [17:24:52] build dev started ... [17:24:52] Proxy added:/alternate-api/ => http://www.transfermarkt.de/api/ [17:24:52] Proxy added:/api/ => https://transfermarkt:eHaM5s6CPxYb@json-app-api.transfermarkt.de/ [17:24:52] clean started ... [17:24:52] clean finished in 7 ms [17:24:52] copy started ... [17:24:52] transpile started ... [17:24:57] transpile finished in 5.80 s [17:24:57] webpack started ... [17:24:58] copy finished in 5.99 s [17:25:07] webpack finished in 9.71 s [17:25:07] sass started ... [17:25:10] sass finished in 2.35 s [17:25:10] build dev finished in 17.91 s [17:25:10] watch ready in 18.27 s [17:25:10] dev server running: http://localhost:8100/ ```

This creates a working version of the app, but the --prod flag is not respected and the main.js not compiled with aot neither minified.

chunhoong commented 7 years ago

@NoNameProvided although i'd suspected, it seems like ng2-translate is not the cause as everything is still fine when i install ng2-module into a fresh vanilla ionic project.

chunhoong commented 7 years ago

Hi @vintage,

So do I. It seems like something is not completed in between, while eventually it still print "build successfully"

Reference untitled

Additional Looks like when --prod flag is enabled, I don't see any alert message from the linter as well.

vintage commented 7 years ago

@rephchunhoong Got it! I've fixed my project by setting up this line https://github.com/driftyco/ionic-conference-app/blob/master/tsconfig.json#L4 to false. Let me know if it solves your problem too.

chunhoong commented 7 years ago

Sorry @vintage, but that doesn't help.

NoNameProvided commented 7 years ago

Got it! I've fixed my project by setting up this line https://github.com/driftyco/ionic-conference-app/blob/master/tsconfig.json#L4 to false.

It's not a fix for me also.

chunhoong commented 7 years ago

@NoNameProvided update to 0.0.48 solved my problem.

NoNameProvided commented 7 years ago

@rephchunhoong It doesnt fix it for me I have opened a new issue in #588

danbucholtz commented 7 years ago

This should be resolved now.

Thanks, Dan