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
juliocbcotta opened this issue Feb 24, 2016 · 17 comments
Closed

exclude test folder from webpack compilation #15

juliocbcotta opened this issue Feb 24, 2016 · 17 comments

Comments

@juliocbcotta
Copy link
Contributor

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

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

Will address this with gulp instead of webpack because

  • you've already tried webpack
  • looks like ionic are coming back to gulp

@juliocbcotta
Copy link
Contributor Author

ok

@lathonez
Copy link
Owner

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

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
Copy link
Owner

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

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

@lathonez
Copy link
Owner

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

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

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

Maybe beforeCompile is perfect, nuke it from the assets folder

@lathonez
Copy link
Owner

42199e8

@juliocbcotta
Copy link
Contributor Author

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

@juliocbcotta
Copy link
Contributor Author

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

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants