Skip to content
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

exclude test folder from webpack compilation #15

Closed
BugsBunnyBR opened this issue Feb 24, 2016 · 17 comments
Closed

exclude test folder from webpack compilation #15

BugsBunnyBR opened this issue Feb 24, 2016 · 17 comments

Comments

@BugsBunnyBR
Copy link
Contributor

@BugsBunnyBR BugsBunnyBR commented Feb 24, 2016

If you decompile the current generated apk, the test folder is being included in the build and shipped with the apk.
I tried to add
exclude: [ /\.(e2e|spec)\.ts$/, /node_modules/, /test/ ]
to webpack.config.js, while it seems to be something right, it is not enough to avoid the packing of the www/build/test folder generated when the tests are executed. If it is too hard to make webpack ignore the folder, can we delete the www/build/test after the tests are executed?

@lathonez
Copy link
Owner

@lathonez lathonez commented Feb 24, 2016

Very interesting, nice catch. We should be able to hack something in gulp at least for cleanup. Would be nicer in webpack tho.

Will have a look at some point.

@lathonez
Copy link
Owner

@lathonez lathonez commented Feb 24, 2016

Will address this with gulp instead of webpack because

  • you've already tried webpack
  • looks like ionic are coming back to gulp
@BugsBunnyBR
Copy link
Contributor Author

@BugsBunnyBR BugsBunnyBR commented Feb 24, 2016

ok

@lathonez
Copy link
Owner

@lathonez lathonez commented Feb 29, 2016

Was thinking to just cleanup the build after test, however this would mean that the local coverage data is lost, which I am not prepared to accept.

Options instead are:

  • wrapping ionic build in a gulp task to delete
  • address the problem in webpack
@lathonez
Copy link
Owner

@lathonez lathonez commented Feb 29, 2016

Digging a bit deeper, all it does is cordova build android. running this gives you spec files inside the APK, as long as they are present in www/build/test. Meaning it's nothing to do with webpack. Webpack is just bundling for ionic.

@lathonez
Copy link
Owner

@lathonez lathonez commented Feb 29, 2016

cordova prepare anrdoid is copying it into platforms/android/assets/www/build/test/, and it's getting compiled as part of the build thereafter

@lathonez
Copy link
Owner

@lathonez lathonez commented Feb 29, 2016

turns out we're using gradle instead of ant, so ant.properties aint gna do much

@lathonez
Copy link
Owner

@lathonez lathonez commented Feb 29, 2016

Have a solution using cordova's beforeBuild hook. It isn't ideal though. I'd rather gradle ignored the test files rather than us deleting them in a beforeHook.

https://cordova.apache.org/docs/en/dev/guide/appdev/hooks/index.html

@lathonez
Copy link
Owner

@lathonez lathonez commented Feb 29, 2016

I'm happy enough from that last answer that there's no clean way of doing it in gradle at the moment.

@lathonez
Copy link
Owner

@lathonez lathonez commented Feb 29, 2016

debating whether:

  • delete after npm test
  • delete with the beforeHook
  • move with the beforeHook

I think I will go with delete with the beforeHook because you can't guarantee npm test will do the cleanup for you. Moving instead of deleting is probably cleaner but can't be bothered with that faff.

@lathonez
Copy link
Owner

@lathonez lathonez commented Feb 29, 2016

Maybe beforeCompile is perfect, nuke it from the assets folder

@lathonez
Copy link
Owner

@lathonez lathonez commented Feb 29, 2016

@lathonez lathonez closed this Feb 29, 2016
@BugsBunnyBR
Copy link
Contributor Author

@BugsBunnyBR BugsBunnyBR commented Feb 29, 2016

Great! Using grdle would help only android builds, so using cordova hooks should solve the issue for android and ios!
Just one question.. don't you have the "hooks" folder in your project? It seems to be the default folder name...

@BugsBunnyBR
Copy link
Contributor Author

@BugsBunnyBR BugsBunnyBR commented Feb 29, 2016

One more thing, "ionic run android" does not trigger the "before_compile" script. Would it be desirable to clean the test build folder when just running? If this is the case, changing from "before_compile" to " after_prepare" seems to solve the issue.

changing color of console.log output would be nice too. :-D

@lathonez
Copy link
Owner

@lathonez lathonez commented Feb 29, 2016

Wow, all great advice - thanks. It's much better now 82be26a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.