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

I create a dist folder after ng build and my directory looks like

C:\Source\angular> ng build

enter image description here

cut and skip the dist folder in another directory

C:\ReSource\angularbuild

enter image description here

After changing 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 can i achieve this? I want to run the dist folder, which is placed in the angularbuild folder withC:\Source\angular>

Let me know the right way to do this.

+6
source share
3 answers

Dist address folder not intended for maintenance

This is a build that you can run without ng commands

ng build :

, ".ts " js , .

, ng serve dist,

index.html dist .

+9

ng , ng- http- npm i -g http-server --save, dist (y):

http-server ./dist

apache , Wamp Xamp, , dist www-, Apache

+2

If you deploy the angular4 project on your web server to a subfolder of DOCUMENT_ROOT / test, you can build it like this:

ng build --prod --base-href "/ test /".

Copy the dist / * files to DOCUMENT_ROOT / test.

Access to the application via: http: // myserver / test . It worked for me.

0
source

All Articles