简体   繁体   中英

Deploy angular2 application

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

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

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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM