Angular-cli: Angular-cli for existing angular2 project

Created on 30 Oct 2016  Â·  6Comments  Â·  Source: angular/angular-cli


OS?

Windows 7

Versions.

run ng --version.
angular-cli: 1.0.0-beta.19-3
node: 6.7.0
os: win32 x64

Repro steps.

created with Angular2 latest version seed project

Mention any other details that might be useful.

  • So I am doing Angular2 / typescript / VS Code for sometime for a POC, I started using latest seed project from Angular2 website.
  • Then I added many more components and routers and modules and services for my POC
  • I used npm install and npm start to test it on my local work machine.
  • POC looks very promising and now we want to show it to bigger group.
  • So I was asked to deploy to a sever.
  • I googled and seems like Angular CLI is the new way and WebPack / Gulp is old way
  • I installed Angular CLI, so I have 2 questions:
  • is there any tutorial to use it for existing project (I couldnt find anything good)
  • So I created a new project using ng new command; now :
    2a. can I just copy my components from old project to src folder and update package.json for missing modules
    2b. or I have to create every class (from my old project) using angular command line : like ng generate

This is really confusing, as Java world we create build.xml or pom file and just running that does everything.

Please help / guide.


Most helpful comment

You can create a new project and copy over all files to your old project and update package.json.

All 6 comments

You can create a new project and copy over all files to your old project and update package.json.

I did it simillar way. Created a new project folder using ng new a copied all src files from old project into a new one (I also wanted to clean up).

ng generate only helps to create code skeletons, but it is completelly optional (I don't use it at all)

Thanks all, I was able to build it with just copying and 2 more changes:

  • template URL used to be starting with "/app/myproject/whervere/template.html", now for angular-cli I had to change to relative url instead of full path starting app folder
  • I was using primeNG and other 3rd party modules, so I had to make changes in angular-cli .json for including more styles:
    "styles": [

    "styles.css",

    "../node_modules/primeng/resources/themes/omega/theme.css",

    "../node_modules/font-awesome/css/font-awesome.min.css",

    "../node_modules/primeng/resources/primeng.min.css"

    ]

So I have a dist folder, how I deploy to server, copy over to webappas folder of Tomcat?
Sorry if this is not appropriate place to post this question.

@skdhir
To deploy your application over tomcat you can copy the dist folder files to a new folder(say... project) and run the below command..

ng build --base-href /project/

Then under the webapps folder of your tomacat you need to paste the project folder. This will be the base url for your application.
You can also refer to #2966 if you get some 404 errors.

This will work... any issues then do post the same.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings