eirslett / frontend-maven-plugin

"Maven-node-grunt-gulp-npm-node-plugin to end all maven-node-grunt-gulp-npm-plugins." A Maven plugin that downloads/installs Node and NPM locally, runs NPM install, Grunt, Gulp and/or Karma.
Apache License 2.0
4.22k stars 868 forks source link

How do you introduce Webpack to a Maven AngularJS application using frontend-maven-plugin #959

Closed patrickByrne99 closed 3 years ago

patrickByrne99 commented 3 years ago

I am looking to Migrate an AngularJS app that uses Maven for dependency to Angular. I know eventually, I will have to switch to node.js but initially, I am looking to incrementally migrate the app. One of the necessary preparation steps is to introduce webpack and this plug in seems to be most appropriate. Do I need to include installing webpack in the pom.xml file or can I just have webpack in my package.json file and get the plug in to install and run node and npm etc.

holgergp commented 3 years ago

Hi Patrick,

what do you mean by "Angular App that is using Maven for dependency"? Do you manage your Angular/Frontend dependecies solely by using Maven? With Web-JARs for example? The "idiomatic"/"most used" way would be to use the package.json approach. Then it would be enough to include/install/configure Webpack just using package.json (and webpack.config.*) Maybe the question implies that you have specific needs in terms of dependency management (maven vs. node)?

Cheers

Holger

patrickByrne99 commented 3 years ago

hi Holger,

This is very helpful thank you. Yes, I manage my Angular/Frontend dependencies solely by using Maven. Is it possible to continue with Maven after the migration to Angular or do you need to migrate to Node too?

holgergp commented 3 years ago

Well that depends. I assume you have some kind of Java Backend and an Angular Frontend. You can surely use Maven for the Backend part and trigger the frontend build with maven. You do not have to (if that was the question) migrate your Backend to node. If you are asking in context of the frontend-maven-plugin, your use case might be that you want to have one place (maven) to trigger your frontend and backend build together. The frontend build then is based on node/npm. So you would switch your Web-Jars to npm-dependencies. However you can still use your Web-JAR approach, if this is what you (or your org) is looking for. You will then however lose a lot of frontend tooling that comes along, for example the angular-cli assumes the npm approach. But then you might not need the frontend-maven-project altogether. Is this somewhat helpful?

patrickByrne99 commented 3 years ago

Yes this has been very helpful thanks a lot! Appreciate it

holgergp commented 3 years ago

Awesome! 😀 Maybe we can close this issue then?