0

I have used below steps to generate dist in production

npm install -g angular2-cli
ng new PROJECT_NAME
cd PROJECT_NAME

After this I have copied all the code it included app folder

ng serve 

it will open my project and runs successfully.

ng build --prod 

Now it is building everything and creating dist folder also, but incomplete. There is no app folder or required files.

Please suggest me the method to generate angular 2 build. I want to host this build in any web server.

raj m
  • 1,863
  • 6
  • 21
  • 37

2 Answers2

0

app folder only for development, when build process complete you got all files you need to deploy on a sever, not app, not src.

Tiep Phan
  • 12,386
  • 3
  • 38
  • 41
  • True that.. I mean it has not considered app folder files. If I run the dist in webserver I am getting error saying that files are missing. Because I have included some node module and script or css files in index.html. – raj m Feb 01 '17 at 06:00
  • change your `base` tag or serve your app at root like this, `myapp.com` for example. if you serve your app at `myapp.com/subapp` , just change base to something like this `` – Tiep Phan Feb 01 '17 at 06:03
  • The problem is assets folder is not created inside the dist. And its only – raj m Feb 01 '17 at 06:04
0

Output of build

  • dist/main.[hash].bundle.js Your application bundled [ size: 13 KB for new Angular CLI application empty, ~3 KB compressed].
  • dist/vendor.[hash].bundle.js Your dependencies (@angular, RxJS...) bundled [ size: 440 KB for new Angular CLI application empty, 99 KB compressed].
  • dist/index.html entry point of your application.
  • dist/inline.[hash].bundle.js webpack loader
  • dist/style.[hash].bundle.css the style definitions
  • dist/assetsresources copied from projectFolder/src/assets

Referred from: How to bundle an Angular app for production

Community
  • 1
  • 1
Habeeb
  • 1,020
  • 16
  • 35
  • True that.. I mean it has not considered app folder files. If I run the dist in webserver I am getting error saying that files are missing. Because I have included some node module and script or css files in index.html. In fact all those files where created. If I host those files in web server it showing error. And assets folder is missing inside – raj m Feb 01 '17 at 06:01
  • I better understood now what is your problem. You have to install the third party library with angular cli (see the documentation https://github.com/angular/angular-cli#3rd-party-library-installation) – Nicolas Henneaux Feb 01 '17 at 06:18