Issue
I wanted to upgrade my small application from angular 1 to angular 2. I am somewhat new to angular 2 and node configurations. My web application use eclipse and maven. The problem is i could not able to configure using angular 2.
What directory structure should I use?
There are maven plugins available but i am bit confused about the directory structure of my angular 2 app.
Solution
Here from the angular site shows several demonstrations of how to structure an angular 2 project. In an eclipse maven web app I would start my client side files into the src/main/resources folder at the same level as the web-inf folder.
Maven pom.xml, include this into your project. Maven-fronted-plugin shouldn't be used for production. Maven will install two folders at the project root level with this setup, node and node_modules.
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v5.3.0</nodeVersion>
<npmVersion>3.3.12</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
package.json add this to the root level of the project before maven clean install.
{
"name": "budget_calculator",
"version": "1.0.0",
"dependencies": {
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "2.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.1",
"@angular/upgrade": "2.0.0-rc.1",
"systemjs": "0.19.27",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"angular2-in-memory-web-api": "0.0.10",
"bootstrap": "^3.3.6"
}
}
Answered By - Grim
Answer Checked By - Candace Johnson (JavaFixing Volunteer)