1

I developed an application in angular2 and now I need to deploy it.

Currently I have a wwww root folder containing:

  • html files
  • js files (generated from typescript)
  • css files (generated from scss)
  • /node_modules/ folders
  • /bower_componenets/ folder

The last two folders (node_modules & bower_components) are very heavy (300 mb and thousands of files) and it is very frustrating copy them using FTP.

Is there a way to keep only the needed files?

Thanks a lot

muetzerich
  • 5,600
  • 7
  • 37
  • 52
user3471528
  • 3,013
  • 6
  • 36
  • 60

2 Answers2

1

You can use gulp for creating bundle from the libraries into single file ex. vendor.js. Also deploying via ftp is very primitive. You should put your app on GitHub or Bitbucket and then log in to the server and pull your repository there and because you don't put the libraries folders into your git repository you will install the libraries on the server. If you want to go more advance you can use tool like Jenkins combined with gulp task for building your application. Jenkins will build your application automatically and deploy to your server on every push on your git repository

Kliment
  • 2,250
  • 3
  • 18
  • 32
  • I use continuus integration for the server side, but, as you said, I dont want to commit 300mb of libs. Can you suggest me a gulp tool to boundle libraries? – user3471528 Jul 08 '16 at 12:51
  • You dont commit the `node_modules` & `bower_components`. you will install npm and bower on the server and install the libraries from the server. You probably have `.gitignore` file that tells git to ignore libraries. You only keep the code on git – Kliment Jul 08 '16 at 12:57
1

The following question could help you if you want to use Gulp:

Note that some answers are for beta versions and packaging changed for RC versions.

Angular-cli could also help you to build your application within the following command:

ng build -prod

Moreover using tree shaking could be interesting to minimize the weight of JavaScript files. See this article for more details:

Community
  • 1
  • 1
Thierry Templier
  • 198,364
  • 44
  • 396
  • 360
  • Thank you Thierry, but what about bower_components and node_mosules? Bith folder contains 300mb of files, I would like to take only what I need – user3471528 Jul 08 '16 at 15:19