Monday, April 13, 2020

angular project publish to github page



command need to follow
npm install -g angular-cli-ghpages
🌹 ng build --prod --base-href https://[username].github.io/[repo]/
🌹 ngh --dir=dist/[project-name]

You need to change <base href="/"> to <base href="./">

ng build ngx-datagrid-test --prod --base-href https://tusharghoshbd.github.io/ngx-datagrid


ngh --dir=dist/ngx-datagrid-test

some important commands use for angular


ng build [project_name] // for library ex "ng build ngx-datatable"

ng build [project_name] --prod //here project name option and only build js file in dist folder

ng serve [project_name] --prod // here project name option and run server in production mode



Can't load angular generated webpage (ng build --prod)


The problem is you're trying to run the application without a server serving the js bundles generated by Angular. Angular will load the js asynchronously.
An option run live-server on the compiled directory
// Install live-server if you haven't
npm install -g live-server

// Run live-server on you dist
cd <project-compile-dist-path>
live-server

// Note: if you don't want to install live-server globally you
// can use npx
npx live-server <path-to-directory>
https://stackoverflow.com/questions/58878123/cant-load-angular-generated-webpage-ng-build-prod





No comments:

Post a Comment

Autoboxing and Unboxing

  Autoboxing  is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper cl...