Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 CLI - How to use /dist folder files created by angular-cli ng build

Tags:

angular

I'm generating dist folder after ng build and my directory looks like

C:\Source\angular> ng build 

enter image description here

cut and past the dist folder in another directory

C:\ReSource\angularbuild 

enter image description here

After changing in Index.html to

<base href="./ReSource/angularbuild/dist"> 

Then

C:\Source\angular> ng serve 

Getting inline.bundle.js,main.bundle.js,styles.bundle.js,vendor.bundle.js,main.bundle.js 404 not found errors

How could i achieve it ? I want to run the dist folder which is placed in angularbuild folder from C:\Source\angular>

Let me know the right way to do it.

like image 772
k11k2 Avatar asked Jun 10 '17 08:06

k11k2


People also ask

What is the use of dist folder in Angular?

The dist folder is the build folder which contains all the files and folders which can be hosted in the server. The dist folder contains the compiled code of your angular application in the format of JavaScript and also the required HTML and CSS files.

Which command compiles an Angular application into an output folder named Dist?

Syntax. ng build command compiles an angular application/library into an output directory named dist at given path.


1 Answers

After ng build, it just needs a server to execute it, instead of ng serve you can install an http-server from your terminal npm i -g http-server --save then execute your project from the dist folder using the command (y) :

http-server ./dist 

Or on apache for who are using Wamp or Xamp for example just copy the entire files on the dist folder inside your www folder, then restart Apache service

like image 138
getName Avatar answered Sep 22 '22 03:09

getName