Giter Site home page Giter Site logo

angular-schule / angular-cli-ghpages Goto Github PK

View Code? Open in Web Editor NEW
937.0 25.0 93.0 5.6 MB

πŸš€ Deploy your πŸ…°οΈAngular app to GitHub pages, Cloudflare Pages or any other Git repo directly from the Angular CLI! Available on NPM.

Home Page: https://www.npmjs.com/package/angular-cli-ghpages

License: MIT License

JavaScript 9.77% TypeScript 90.09% HTML 0.14%
angular gh-pages travis-ci angular-cli-ghpages ng-deploy angular-cli circle-ci cloudflare-pages github-actions github-pages

angular-cli-ghpages's Introduction

angular-cli-ghpages

NPM version GitHub Actions The MIT License

Deploy your Angular app to GitHub Pages, Cloudflare Pages or any other Git repo directly from the Angular CLI! πŸš€

Screenshot

Table of contents:

  1. πŸ“– Changelog
  2. ⚠️ Prerequisites
  3. πŸš€ Quick Start (local development)
  4. βš™οΈ Installation
  5. πŸš€ Continuous Delivery
  6. πŸ“¦ Deployment Options
  7. πŸ“ Configuration File
  8. 🌍 Environments
  9. ⁉️ FAQ

πŸ“– Changelog

A detailed changelog is available in the releases section.

⚠️ BREAKING CHANGE (v2)

The internal build of Angular has changed with Angular 17. Unfortunately, there are now a lot of different build targets and builders. We will try to guess the correct build target, based on the usual conventions to name them. The conventions are shown below, try to specify the build target more and more explicitly until the project compiles.

In the following example, your app is called test and you want to deploy the production build.

ng deploy

If this doesn't work, try this:

ng deploy --build-target=test

If this doesn't work, try this:

ng deploy --build-target=test:build:production

You can also and modify your angular.json to archive the same:

{
  "deploy": {
    "builder": "angular-cli-ghpages:deploy",
    "options": {
      "buildTarget": "test:build:production"
    }
  }
}

For your convenience, you can also use prerenderTarget (which adds the suffix :prerender:production). There is no support for universalBuildTarget or serverTarget because Github Pages only supports static assets and no Server-Side Rendering!

We will then try to deploy the dist/test/browser folder to Github Pages. If this is not the folder that you want to serve, you should explicitly specify the directory with the --dir option:

ng deploy --dir=dist/test/browser

This new build logic is a breaking change, therefore angular-cli-ghpages v2 only supports Angular 17 and higher. For previous versions of Angular, use angular-cli-ghpages v1.x.

⚠️ Prerequisites

This command has the following prerequisites:

  • Git 1.9 or higher (execute git --version to check your version)
  • Angular project created via Angular CLI v17 or greater
  • older Angular projects can still use a v1.x version or use the standalone program. See the documentation at README_standalone.

πŸš€ Quick Start (local development)

This quick start assumes that you are starting from scratch. If you already have an existing Angular project on GitHub, skip step 1 and 2.

  1. Install the latest version of the Angular CLI globally and create a new Angular project.

    npm install -g @angular/cli
    ng new your-angular-project --defaults
    cd your-angular-project
  2. By default the Angular CLI initializes a Git repository for you.
    To add a new remote for GitHub, use the git remote add command:

    git remote add origin https://github.com/<username>/<repositoryname>.git

    Hints:

    • Create a new empty GitHub repository first.
    • Replace <username> and <repositoryname> with your username from GitHub and the name of your new repository.
    • Please enter the URL https://github.com/<username>/<repositoryname>.git into your browser – you should see your existing repository on GitHub.
    • Please double-check that you have the necessary rights to make changes to the given project!
  3. Add angular-cli-ghpages to your project. For details, see the installation section.

    ng add angular-cli-ghpages
  4. Deploy your project to GitHub pages with all default settings. Your project will be automatically built in production mode.

    ng deploy --base-href=/<repositoryname>/

    Which is the same as:

    ng deploy your-angular-project --base-href=/<repositoryname>/

    Please be aware of the --base-href option. It is necessary when your project will be deployed to a non-root folder. See more details below.

  5. Your project should be available at https://<username>.github.io/<repositoryname>.
    Learn more about GitHub pages on the official website.

βš™οΈ Installation

angular-cli-ghpages can be installed via ng add. This will install the NPM package and add the necessary deploy configuration to your angular.json file.

ng add angular-cli-ghpages

If you have multiple projects in one workspace, you should manually define the project name:

ng add angular-cli-ghpages --project MYPROJECTNAME

πŸš€ Continuous Delivery

If you run this command from a CI/CD environment, the deployment will most likely not work out of the box. For security reasons, those environments usually have read-only privileges or you haven't set up Git correctly. Therefore you should take a look at "personal access tokens" GH_TOKEN (which works everywhere) and the "installation access token" GITHUB_TOKEN (which is exclusively provided by GitHub actions). In short: a token replaces username and password and is a safer choice because a token can be revoked at any time.

All you need to do is to set an environment variable called GH_TOKEN (or PERSONAL_TOKEN) in your CI/CD environment. For GitHub Actions, you can also use the GITHUB_TOKEN which provides more security and requires no additional setup. All the tokens only work if the remote repository uses the HTTPS scheme. Tokens are generally not supported for Git over SSH.

If the current working directory is already a git repository, you don't need to specify the repository again. The current remote repository with the name origin will be used in this case. You can also override the repository setting using the --repo option.

If you specify all the three options (--repo, --name and --email), then angular-cli-ghpages will also work in directories that are not under version control at all.

ng deploy --repo=https://github.com/<username>/<repositoryname>.git --name="Your Git Username" [email protected]

(replace <username> and <repositoryname> with your username from GitHub and the name of your repository)

ℹ️ Note for GitHub Actions

The GITHUB_TOKEN (installation access token) will only trigger a release of a new website if the action runs in a private repository. In a public repo, a commit is generated, but the site does not change. See this GitHub Community post for more info. If your repo is public, you must still use the GH_TOKEN (personal access token).

πŸ“¦ Deployment Options

--base-href

  • optional
  • Default: undefined (string)
  • Example:
    • ng deploy – The tag <base href="/"> remains unchanged in your index.html
    • ng deploy --base-href=/the-repositoryname/ – The tag <base href="/the-repositoryname/"> is added to your index.html

Specifies the base URL for the application being built. Same as ng build --base-href=/XXX/

ℹ️ Please read the next lines carefully, or you will get 404 errors in case of a wrong configuration!

A) You don't want to use a custom domain

If you don't want to use an own domain, then your later URL of your hosted Angular project should look like this: https://your-username.github.io/the-repositoryname. In this case you have to adjust the --base-href accordingly:

ng deploy --base-href=/the-repositoryname/
B) You want to use a custom domain

If you want to use your own domain, then you don't have to adjust --base-href. However, it is now necessary to set the --cname parameter!

ng deploy --cname=example.org

See the option --cname for more information!

--build-target

  • optional
  • Default: undefined (string)
  • Example:
    • ng deploy – Angular project is built in production mode
    • ng deploy --build-target=test – Angular project is using the build configuration test (this configuration must exist in the angular.json file)

If no buildTarget is set, the production build of the default project will be chosen. The buildTarget simply points to an existing build configuration for your project, as specified in the configurations section of angular.json. Most projects have a default configuration and a production configuration (commonly activated by using the --prod flag) but it is possible to specify as many build configurations as needed.

This is equivalent to calling the command ng build --configuration=XXX. This command has no effect if the option --no-build is active.

⚠️ BREAKING CHANGE (v1)

This option was called --configuration in previous versions.

BEFORE (does not work):

ng deploy --configuration=test

NOW:

ng deploy --build-target=test

--no-build

  • optional
  • Default: false (string)
  • Example:
    • ng deploy – Angular project is build in production mode before the deployment
    • ng deploy --no-build – Angular project is NOT build

Skip build process during deployment. This can be used when you are sure that you haven't changed anything and want to deploy with the latest artifact. This command causes the --build-target setting to have no effect.

--repo

  • optional
  • Default: URL of the origin remote of the current dir (assumes a Git repository)
  • Example: ng deploy --repo=https://github.com/<username>/<repositoryname>.git

This specifies the target repository. If none is given as an option, the repository is discovered from the current working directory.

By default, this command assumes that the current working directory is a Git repository, and that you want to push changes to the origin remote. If instead your files are not in a git repository, or if you want to push to another repository, you can provide the repository URL in the repo option.

ℹ️ Hint

Set an environment variable with the name GH_TOKEN / PERSONAL_TOKEN or GITHUB_TOKEN and it will be automatically added to the URL, if it uses the HTTPS shema (it must start with https://github.com). Tokens are generally not supported for Git over SSH (starts with [email protected]).

Learn more about "personal access tokens" here (GH_TOKEN) and about the "installation access token" here (GITHUB_TOKEN). PERSONAL_TOKEN is an alias for GH_TOKEN.

--message

  • optional
  • Default: Auto-generated commit (string)
  • Example: ng deploy --message="What could possibly go wrong?"

The commit message must be wrapped in quotes if there are any spaces in the text.
Some additional text is always added to the message, if the command runs on Travis CI, Circle CI or GitHub Actions.

--branch

  • optional
  • Default: gh-pages (string)
  • Example: ng deploy --branch=master

The name of the branch you'll be pushing to. The default uses GitHub's gh-pages branch, but this can be configured to push to any branch on any remote. You have to change this to master if you are pushing to a GitHub organization page (instead of a GitHub user page).

--name & --email

  • optional
  • Default: value of git config user.name and git config user.email
  • Example: ng deploy --name="Displayed Username" [email protected]

If you run the command in a repository without user.name or user.email Git config properties (or on a machine without these global config properties), you must provide user info before Git allows you to commit. In this case, provide both name and email string values to identify the committer.

--no-dotfiles

  • optional
  • Default: Dotfiles are created (boolean true)
  • Example:
    • ng deploy – Dotfiles are included by default.
    • ng deploy --no-dotfiles – Dotfiles are ignored.

The command includes dotfiles by default (e.g. .htaccess will be committed). With --no-dotfiles files starting with . are ignored.

--no-notfound

  • optional
  • Default: 404.html file is created (boolean true)
  • Example:
    • ng deploy – A 404.html file is created by default.
    • ng deploy --no-notfound – No 404.html file is created.

By default a 404.html file is created, because this is the only known workaround to avoid 404 error messages on GitHub Pages. For Cloudflare Pages we highly recommend to disable the 404.html file by setting this switch to true! see #178

--no-nojekyll

  • optional
  • Default: .nojekyll file is created (boolean true)
  • Example:
    • ng deploy – A .nojekyll file is created by default.
    • ng deploy --no-nojekyll – No .nojekyll file is created.

By default a .nojekyll file is created, because we assume you don't want to compile the build again with Jekyll.

Explanation: By creating such a file in the root of your pages repo, you will bypass the Jekyll static site generator on GitHub Pages. Static content is still delivered – even without Jekyll. But now the deployment will be a bit faster. This is also necessary if your site uses files or directories that start with _underscores since Jekyll considers these to be special resources and does not copy them to the final site. The same applies to .txt files in your assets folder: They will just disappear if Jekyll processes the build. see #160

--cname

  • optional
  • Default: undefined (string) – No CNAME file is generated
  • Example:
    • ng deploy --cname=example.com

A CNAME file will be created enabling you to use a custom domain. More information on GitHub Pages using a custom domain.

--dir

  • optional
  • Default: undefined (string) – Conventions will be used to guess the correct directory in your dist folder.
  • Example:
    • ng deploy --dir=dist/completely-different-folder/en

Overrides the directory for all published sources, relative to the current working directory.

--dry-run

  • optional
  • Default: false (boolean)
  • Example:
    • ng deploy – Normal behavior: Changes are applied.
    • ng deploy --dry-run – No changes are applied at all.

Run through without making any changes. This can be very useful because it outputs what would happen without doing anything.

πŸ“ Configuration File

To avoid all these command-line cmd options, you can write down your configuration in the angular.json file in the options attribute of your deploy project's architect. Just change the kebab-case to lower camel case. This is the notation of all options in lower camel case:

  • baseHref
  • buildTarget
  • noBuild
  • repo
  • message
  • branch
  • name
  • email
  • noDotfiles
  • noNotfound
  • noNojekyll
  • cname
  • dir
  • dryRun

A list of all available options is also available here.

Example:

ng deploy --base-href=https://angular-schule.github.io/angular-cli-ghpages/ --name="Angular Schule Team" [email protected]

becomes

"deploy": {
  "builder": "angular-cli-ghpages:deploy",
  "options": {
    "baseHref": "https://angular-schule.github.io/angular-cli-ghpages/",
    "name": "Angular Schule Team",
    "email": "[email protected]"
  }
}

Now you can just run ng deploy without all the options in the command line! πŸ˜„

ℹ️ Hint

You can always use the --dry-run option to verify if your configuration is right. The project will build but not deploy.

🌍 Environments

We have seen angular-cli-ghpages running on various environments, like Travis CI, CircleCi or Github Actions. Please share your knowledge by writing an article about how to set up the deployment.

  1. GitHub Actions
  2. Travis CI
  3. CircleCI

⁉️ FAQ

Before posting any issue, please read the FAQ first. See the contributors documentation at README_contributors if you want to debug and test this project.

License

Code released under the MIT license.


Β© 2017-2024 https://angular.schule

This project is made on top of tschaub/gh-pages.
Thank you very much for this great foundation!

angular-cli-ghpages's People

Contributors

abigailwillow avatar alan-agius4 avatar beeman avatar cyberexplosion avatar d-koppenhagen avatar dependabot[bot] avatar dianjuar avatar djoldman avatar edricchan03 avatar fmalcher avatar icepeng avatar irsali avatar johanneshoppe avatar masaxsuzu avatar mgechev avatar olof-nord avatar pfleigo avatar santoshyadavdev avatar tinesoft avatar wingsuitist avatar wuglyakbolgoink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-cli-ghpages's Issues

Angular 7 project doesn't publish on Github - shows only ReadMe file (I've used GitHub Pages)

When I publish Angular projects I usually always do the same thing.. but for some reason it doesn't work anymore. That's exactly what I wrote: (The repo name is movies)

git init

git remote add origin <MyGitHubLink>

git add *

git commit -m 'first-commit'

git push -u origin master

ng build --prod --base-href https://itayperry.github.io/movies (from ghpages on github settings)

ngh --dir dist/movies

Then I get the message *** Successfully published! but all I see is the README file.

Please help me!!

The repository: https://github.com/itayperry/movies

The published page: https://itayperry.github.io/movies/

Better command line options / Unhandled promise rejection

First, I wasn't clear if I was supposed to replace USERNAME and REPOSITORY here:
ng build --prod --base-href "https://USERNAME.github.io/REPOSITORY"

I assumed I was supposed to do that, so I first did this:

ng build --prod --base-href "https://github.com/scottschafer/toilet-run"

I get this error when I run "ngh":

An error occurred!

(node:36422) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Unspecified error (run without silent option for detail)

I tried "ngh --silent=false" and other variations, but it give me no more details.

index.html could not be copied to 404.html. Continuing without an error.

ngh --dir dist/third
sudo angular-cli-ghpages --branch gh-pages
angular-cli-ghpages
index.html could not be copied to 404.html. Continuing without an error.
An error occurred!
Error: Unspecified error (run without silent option for detail)
then i tried
sudo npm run deploy
then it says successfully published
with error listed above

fix the document: --prod vs. --env=prod

image
angular CLI update to new version
you should fix
from: ng build --prod --base-href "https://USERNAME.github.io/REPOSITORY/" to : ng build --prod --base-href "https://USERNAME.github.io/REPOSITORY/"

this will make this won't render error Can't resolve './$$_gendir/app/app.module.ngfactory'

Avoid keeping commit history on gh pages branch

Hallo!

I have a question, is it possible to deploy on gh pages and avoid keeping the commit history with your package?

For example, Travis CI has the option keep-history when deploying on gh pages to configure this behavior and its default is false.

If you want to know my opinion is a good feature, because people usually don't want to keep track of their github pages deployment, that is just an environment to be able to serve your files, even they are almost not human readable if you are using webpack based projects .

I have an Angular project and if you see its gh-pages branch doesn't give any useful information

Error: No such device or address

Getting this error. Kindly suggest.
OS: Window 10

ng build --prod --base-href "https://sumitridhal.github.io/the-new-school/"
ngh --no-silent

An error occurred!
 { Error
    at ChildProcess.<anonymous> (C:\Users\Sumit Ridhal\AppData\Roaming\npm\node_modules\angular-cli-ghpages\node_modules\gh-pages\lib\git.js:47:23)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:897:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
  code: 128,
  message: 'bash: /dev/tty: No such device or address\nerror: failed to execute prompt script (exit code 1)\nfatal: could not read Username for \'https://github.com\': Invalid argument\n',
  name: 'ProcessError' }

Doest not deploy to gh-pages

Hi

I am following the same steps that you have mentioned in the usage section but I am unable to publish to gh-pages. The build completes successfully and the ngh command also runs without any issues. Here is a screenshot:

image

When I see my github repo, I see only one branch:
image

Could you please let me know what I am missing?

Local installation

@petersgiles

@JohannesHoppe yep that's the way it happened for me.

I tried installing npm install --save-dev angular-cli-ghpages and it didn't make the ngh available so I uninstalled it and did npm install -g angular-cli-ghpages and it worked.

macOS Sierra

node: 6.9.5
os: darwin x64
@angular/common: 2.4.7
@angular/compiler: 2.4.7
@angular/core: 2.4.7
@angular/flex-layout: 2.0.0-beta.5
@angular/forms: 2.4.7
@angular/http: 2.4.7
@angular/material: 2.0.0-beta.1
@angular/platform-browser: 2.4.7
@angular/platform-browser-dynamic: 2.4.7
@angular/router: 3.4.7
@angular/cli: 1.0.0-beta.31
@angular/compiler-cli: 2.4.7

see angular/angular-cli#4385 (comment)

Error: Could not resolve hostname github.com:sumitridhal

Cloning ssh://[email protected]:sumitridhal/sumitridhal.github.io.git into ......\Users\Sumit Ridhal\AppData\Roaming\npm\node_modules\angular-cli-ghpages\node_modules\gh-pages.cache

An error occurred!
{ Error
at ChildProcess. (C:\Users\Sumit Ridhal\AppData\Roaming\npm\node_modules\angular-cli-ghpages\node_modules\gh-pages\lib\git.js:47:23)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at maybeClose (internal/child_process.js:897:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
code: 128,
message: 'Cloning into '..\..\..\Users\Sumit Ridhal\AppData\Roaming\npm\node_modules\angular-cli-ghpages\node_modules\gh-pages\.cache'...\nssh: Could not resolve hostname github.com:sumitridhal: Name or service not known\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n',
name: 'ProcessError' }

could not read Username for 'https://github.com': Invalid argument

Hi

I'm following usage guide, but see error from issue name. What can be the reason? Here is my log with no-silent option:
...
Copying files
Adding all
Committing
Pushing
An error occurred!
(node:5644) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): ProcessError: bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': Invalid argument

Deployed site: Uncaught SyntaxError: Unexpected token <

After building the site with:

ng build --prod --base-href "https;//<username>.github.io/<reponame>/

I can run the site with no issues on a local server.

However, after publishing via ngh, the online site just gives the following error 4 times:

SyntaxError: Unexpected token < (index):1

No other errors or information is given, so I have no idea what to do.

Facing issue for deployment with Angular6

 npm install -g angular-cli-ghpages
$ ng build --prod --base-href https://sahilkatia.github.io/resume/

ngh --dir dist/resume

Even then I am facing error

below is the screen
capture

Can only enter page from root

I used the angular-cli-ghpages tool and it worked perfectly fine, with deploying it on the gh-pages branch. But I only can access my application from the root directory and not just using a specific URL.

Has anyone came across this problem?

"index.html could not be copied to 404.html. Continuing without an error." for Angular 6

Created an empty Angular 6 application. Installed ngh globally and then ran the next two commands:

ng build --prod --base-href https://dutchmandavid.github.io/angular-io-code
ngh

then got this as output:

(node:1756) ExperimentalWarning: The fs.promises API is experimental
index.html could not be copied to 404.html. Continuing without an error.
Successfully published!

The url itself (https://dutchmandavid.github.io/angular-io-code) now gives the next error:

File not found

The site configured at this address does not contain the requested file.

Copying index.html and renaming it to 404.html does nothing - even after rebuilding and ngh-ing it again.


Archive for if the page ever changes: http://archive.is/uQxVg (web.archive.org didn't want to cooperate)

Deploy to a User GitHub Page

After reading up on GutHub Pages I found out that if you want to use a User/Org repository on GitHub Pages instead of a project repository (.github.io vs. .github.io/Project-Name ) you have to store everything in the master branch.

I was wondering if angular-cli-ghpages had a way to deal with this or if it's better to just create a repository for a website?

I'm asking because I'd like to use programazing.github.io as a portfolio/resume website even though I will eventually use a custom domain later on.

DeprecationWarning: Unhandled promise rejections are deprecated.

by @tkow
from angular/angular-cli#4385 (comment)

However, I have another problem catch message says "An error occurred!" in node v.7.4.0.
and details bellow.

(node:6042) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Unspecified error (run without silent option for detail)
(node:6042) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Please tell me how it cause to address, if there are someone feel not uncomfortable.I'll try to downgrade node version.Then , I move to angular-buch/angular-cli-ghpages repository for this ploblem is not angular-cli.

Deploying results in error on Linux

This use to work, but it's been a while since I deployed. Following the steps from the README now fails in an error.

Versions

Angular: ^7.2.0
angular-cli-ghpages: ^0.5.3

Step one, build goes well (The "dist" folder does not contain a subfolder).

$ ng build --prod --base-href="http://dynomightcss.com/"
                                                                                 
Date: 2019-01-20T11:42:06.394Z
Hash: 5a3ccc8818540c70d030
Time: 38591ms
chunk {0} runtime.b57bf819d5bdce77f1c7.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main.dd74da47309df22e6f90.js (main) 1.42 MB [initial] [rendered]
chunk {2} polyfills.85b8de986383d623e591.js (polyfills) 41 kB [initial] [rendered]
chunk {3} styles.1f8b4bee48110b4ecff6.css (styles) 117 kB [initial] [rendered]
chunk {scripts} scripts.0409edb92abecdc246d4.js (scripts) 9.37 kB [entry] [rendered]

Step two, deploy fails.

$ npx angular-cli-ghpages
*** An error occurred!

Error: Unspecified error (run without silent option for detail)
    at /home/yadav/projects/dm-css/website/dynomightcss/node_modules/gh-pages/lib/index.js:232:19
    at _rejected (/home/yadav/projects/dm-css/website/dynomightcss/node_modules/q/q.js:844:24)
    at /home/yadav/projects/dm-css/website/dynomightcss/node_modules/q/q.js:870:30
    at Promise.when (/home/yadav/projects/dm-css/website/dynomightcss/node_modules/q/q.js:1122:31)
    at Promise.promise.promiseDispatch (/home/yadav/projects/dm-css/website/dynomightcss/node_modules/q/q.js:788:41)
    at /home/yadav/projects/dm-css/website/dynomightcss/node_modules/q/q.js:604:44
    at runSingle (/home/yadav/projects/dm-css/website/dynomightcss/node_modules/q/q.js:137:13)
    at flush (/home/yadav/projects/dm-css/website/dynomightcss/node_modules/q/q.js:125:13)
    at process._tickCallback (internal/process/next_tick.js:61:11)

Permission Denied

I am getting the following error-
`sudo ngh --branch=master --no-silent
Cloning [email protected]:abhinavagrawal1995/web-portfolio-angular.git into ../../../../usr/lib/node_modules/angular-cli-ghpages/node_modules/gh-pages/.cache

An error occurred!
{ Error
at ChildProcess. (/usr/lib/node_modules/angular-cli-ghpages/node_modules/gh-pages/lib/git.js:47:23)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:194:7)
at maybeClose (internal/child_process.js:899:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
code: 128,
message: 'Cloning into '../../../../usr/lib/node_modules/angular-cli-ghpages/node_modules/gh-pages/.cache'...\nPermission denied (publickey).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n',
name: 'ProcessError' }`

I have verified that the repo is correct.

could not read Username for 'https://github.com'

D:\projects\angular-gridster2>npm run deploy-demo

> [email protected] deploy-demo D:\projects\angular-gridster2
> ngh --dir=demo --no-silent --name='Tiberiu Zuld' --email='[email protected]'

Cloning https://github.com/tiberiuzuld/angular-gridster2.git into node_modules\gh-pages\.cache

Cleaning

Fetching origin

Checking out origin/gh-pages

Removing files

Copying files

Adding all

Committing

Pushing

An error occurred!
 { ProcessError: bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': No error

    at ChildProcess.<anonymous> (D:\projects\angular-gridster2\node_modules\gh-pages\lib\git.js:47:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
  code: 128,
  message: 'bash: /dev/tty: No such device or address\nerror: failed to execute prompt script (exit code 1)\nfatal: could not read Username for
\'https://github.com\': No error\n',
  name: 'ProcessError' }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] deploy-demo: `ngh --dir=demo --no-silent --name='Tiberiu Zuld' --email='[email protected]'`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] deploy-demo script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!  debug.log

Tried to run this lib to publish my library on gh-pages but was not able to run it on:

OS: Win10
Node: 8.11.0
Npm: 5.8.0

Tried with both the package installed globally and locally.
Tried these commands:

// will run from local package
npm run deploy-demo
// in package.json had "deploy-demo": "ngh --dir=demo"
// will run from global package
ngh --dir=demo --no-silent
ngh --dir=demo --no-silent --name='Tiberiu Zuld' --email='[email protected]'

Running any of the commands I get to same error.

ngh is an independent package in itself.

I have used this module and it's like super awesome, was curious about the working mechanism of it so I searched for the ngh package. To my surprise, ngh is both an alias to this(angular-cli-ghpages) package and a proper command for triggering the ngh module. Also installing both of them causes a possible name conflict.

Stuck on running GitHub page command in Azure Pipeline

When The Asure Pipeline reaches at publishing to GitHub it sticks about 30 minutes then shuts down.

in Package.json I have:

"publish-to-git": "ngh --dir=dist/projectname",

Azure Output:
2018-12-18T06:21:50.0328199Z [command]C:\Windows\system32\cmd.exe /D /S /C "D:\a\_tool\node\10.14.2\x64\npm.cmd run publish-to-git"

2018-12-18T06:48:15.6137049Z ##[error]The operation was canceled.

Causes `ng build` error (can't resolve module @angular/core/src/di/opaque_token)

can't resolve module @angular/core/src/di/opaque_token from DIR\src\index.ts
symbol.getDeclarations is not a function
TypeError: symbol.getDeclarations is not a function
    at ReflectorHost.findDeclaration (DIR\node_modules\@angular\compiler-cli\src\reflector_host.js:179:38)
    at StaticReflector.initializeConversionMap (DIR\node_modules\@angular\compiler-cli\src\static_reflector.js:145:38)
    at new StaticReflector (DIR\node_modules\@angular\compiler-cli\src\static_reflector.js:42:14)
    at AotPlugin._setupOptions (DIR\node_modules\@ngtools\webpack\src\plugin.js:137:27)
    at new AotPlugin (DIR\node_modules\@ngtools\webpack\src\plugin.js:37:14)
    at Object.exports.getWebpackNonAotConfigPartial (DIR\node_modules\angular-cli\models\webpack-build-typescript.js:20:13)
    at new NgCliWebpackConfig (DIR\node_modules\angular-cli\models\webpack-config.js:23:42)
    at Class.run (DIR\node_modules\angular-cli\tasks\build-webpack.js:17:22)
    at Class.run (DIR\node_modules\angular-cli\commands\build.js:54:26)
    at Class.<anonymous> (DIR\node_modules\angular-cli\angular-cli\lib\models\command.js:152:17)
    at process._tickCallback (internal/process/next_tick.js:103:7)

ProcessError: fatal: could not create work tree dir, Permission denied

MacBook-Pro-gkucmierz:coin-tools gkucmierz$ ngh --no-silent
Cloning [email protected]:gkucmierz/coin-tools.git into ../../../../usr/local/lib/node_modules/angular-cli-ghpages/node_modules/gh-pages/.cache

An error occurred!

(node:17668) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): ProcessError: fatal: could not create work tree dir '../../../../usr/local/lib/node_modules/angular-cli-ghpages/node_modules/gh-pages/.cache': Permission denied

Deployed Site :Error: Cannot find module 'fs-extra'

After building the site with:

ng build --prod --base-href "https;//.github.io//

I can run the site with no issues on a local server.

However, during publishing via ngh,

the gitBash gives error as:-
internal/modules/cjs/loader.js:584
throw err;
^

Error: Cannot find module 'fs-extra'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (C:\Users\Abhi\AppData\Roaming\npm\node_modules\angular-cli-ghpages\index.js:3:9)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)

After installing & deploying "fs-extra" he error still exist..
Plz help me..
@JohannesHoppe

/dist in .gitignore

After running the commands to deploy the app to Github pages, the app is deployed to Github but the URL https://USER-NAME.github.io/REPO-NAME shows just the Loading... heading. The workaround that I found was to remove the /dist folder from the .gitignore before deploying. It used to work fine and only encountered this problem today.

No commit is made to repo, but ngh prints `Successfully published!`

this is what i used

$ sudo ngh --branch=master --repo=https://github.com/Code-Freaks/Code-Freaks.github.io.git -S
Password:
Cloning https://github.com/Code-Freaks/Code-Freaks.github.io.git into ../../../../usr/local/lib/node_modules/angular-cli-ghpages/node_modules/gh-pages/.cache

Cleaning

Fetching origin

Checking out origin/master

Removing files

Copying files

Adding all

Committing

Pushing

Successfully published!

but no commits are made to the master branch

unable to deploy in windows

unable to deploy in windows by running this command
ngh --no-silent false --name="nileshpatel17" --email="[email protected]"
Below is the log

Cloning https://github.com/NileshPatel17/ngrx-example-app.git into C:\Users\admin\AppData\Roaming\npm\node_mod                                                         
ules\angular-cli-ghpages\node_modules\gh-pages\.cache                                                                                                                  
                                                                                                                                                                       
Cleaning                                                                                                                                                               
                                                                                                                                                                       
Fetching origin                                                                                                                                                        
                                                                                                                                                                       
Checking out origin/gh-pages                                                                                                                                           
                                                                                                                                                                       
Removing files                                                                                                                                                         
                                                                                                                                                                       
Copying files                                                                                                                                                          
                                                                                                                                                                       
Adding all                                                                                                                                                             
                                                                                                                                                                       
Committing                                                                                                                                                             
                                                                                                                                                                       
Pushing                                                                                                                                                                
                                                                                                                                                                       
An error occurred!                                                                                                                                                     
 { ProcessError: bash: /dev/tty: No such device or address                                                                                                             
error: failed to execute prompt script (exit code 1)                                                                                                                   
fatal: could not read Username for 'https://github.com': Invalid argument                                                                                              
                                                                                                                                                                       
    at ChildProcess.<anonymous> (C:\Users\admin\AppData\Roaming\npm\node_modules\angular-cli-ghpages\node_modules\gh-pages\lib\git.js:47:23)                           
    at emitTwo (events.js:106:13)                                                                                                                                      
    at ChildProcess.emit (events.js:191:7)                                                                                                                             
    at maybeClose (internal/child_process.js:877:16)                                                                                                                   
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)                                                                                           
  code: 128,                                                                                                                                                           
  message: 'bash: /dev/tty: No such device or address\nerror: failed to execute prompt script (exit code 1)\nfatal: could not read Username for \'https://github.com\':
Invalid argument\n',                                                                                                                                                   
  name: 'ProcessError' }                                                                                                                                               

window version: Windows 7 Ultimate SP1

CORS error when requesting dist files

Hello. Thank you for your work!
I am having CORS error:
Access to script at 'https://USER_NAME.github.io/REPO_NAME/main-es2015.25489881bec059fbf1a6.js' from origin 'https://USER_NAME.github.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource
And it is all the same for :
https://USER_NAME.github.io/REPO_NAME/runtime-es2015.858f8dd898b75fe86926.js
and
https://USER_NAME.github.io/REPO_NAME/polyfills-es2015.5728f680576ca47e99fe.js
Your help is appreciated

Updating Github repo with modified build

Hello, I'm very new to Angular 2-5 and still learning Git/Github.

I figured out how to use ng build to deploy an Angular app to Github Pages using angular-cli-ghpages. It is working but it's still the original version. I have since changed some code, and tried to rebuild and re-deploy using angular-cli-ghpages. I'm not sure how to update the app, or re-deploy. I can't find much documentation on this subject.

Can anyone point me in the right direction? Once again, I just want to learn how to successfully rebuild an app, and re-deploy to my Github Pages using angular-cli-ghpages, or "update" the app.

Thanks,
Ron R

index.html could not be copied to 404.html. Continuing without an error.

I created a simple app in angular 6 and trying to deploy it on github pages, Successfully run the following command
ng build --prod --base-href "repo url"

But when run ngh command, Got the error,

index.html could not be copied to 404.html. Continuing without an error.
(Hint: are you sure that you have setup the --dir parameter correctly?)
{ Error: ENOENT: no such file or directory, lstat 'D:\Programming\Javascript\Angular\my-app\dist\index.html'
errno: -4058,
code: 'ENOENT',
syscall: 'lstat',
path: 'D:\Programming\Javascript\Angular\my-app\dist\index.html' }
*** Successfully published!

Angular 6 routing broken with custom domain

I pushed my project up to my repo using angular-cli-ghpages back when my project was still a github.io project and the website worked fine, but as soon as I added the CNAME to the dist folder and added the IPs to Google Domains, I went to access the site, the site comes up, but only the nav and footer. The routing is also broken.

I am not sure why adding a custom domain would break the website. Any ideas?

Here is the repo: https://github.com/RockGuitarist1/WaypointYouthCommunityCenter
Here is the website: http://waypointcommunitycenter.org/

Routing / href issue

I apologize if this is not the correct place to post this.

I keep getting this error in my web console. I was able to remove my routing and everything still worked luckily since I have a one page scrolling application, but how does one solve this issue otherwise. I have tried stack overflow searches, ect... for about an hour with little to help me.
http://andrewvetovitz.com is my web domain.
https://andrewvetovitz.github.io/andrewvetovitz.github.io-personal-website/ is the github / repository domain.

ERROR Error: Uncaught (in promise): SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'https://andrewvetovitz.github.io/andrewvetovitz.github.io-personal-website/' cannot be created in a document with origin 'http://andrewvetovitz.com' and URL 'http://andrewvetovitz.com/'.
Error: Failed to execute 'replaceState' on 'History': A history state object with URL 'https://andrewvetovitz.github.io/andrewvetovitz.github.io-personal-website/' cannot be created in a document with origin 'http://andrewvetovitz.com' and URL 'http://andrewvetovitz.com/'.
at BrowserPlatformLocation.webpackJsonp.../../../platform-browser/esm5/platform-browser.js.BrowserPlatformLocation.replaceState (platform-browser.js:1770)
at

Travis-CI after success:

How do I confirm travis-ci after_success to deploy ngh after ng build --prod was successful?
Right now I got this far

The command "ng build --prod" exited with 0.
after_success.1
0.01s$ echo "wangkanai.com" > dist/CNAME
after_success.2
1.58s$ ngh --branch=master
An error occurred!
 Error: Unspecified error (run without silent option for detail)
    at /home/travis/.nvm/versions/node/v9.8.0/lib/node_modules/angular-cli-ghpages/node_modules/gh-pages/lib/index.js:232:19
    at _rejected (/home/travis/.nvm/versions/node/v9.8.0/lib/node_modules/angular-cli-ghpages/node_modules/q/q.js:844:24)
    at /home/travis/.nvm/versions/node/v9.8.0/lib/node_modules/angular-cli-ghpages/node_modules/q/q.js:870:30
    at Promise.when (/home/travis/.nvm/versions/node/v9.8.0/lib/node_modules/angular-cli-ghpages/node_modules/q/q.js:1122:31)
    at Promise.promise.promiseDispatch (/home/travis/.nvm/versions/node/v9.8.0/lib/node_modules/angular-cli-ghpages/node_modules/q/q.js:788:41)
    at /home/travis/.nvm/versions/node/v9.8.0/lib/node_modules/angular-cli-ghpages/node_modules/q/q.js:604:44
    at runSingle (/home/travis/.nvm/versions/node/v9.8.0/lib/node_modules/angular-cli-ghpages/node_modules/q/q.js:137:13)
    at flush (/home/travis/.nvm/versions/node/v9.8.0/lib/node_modules/angular-cli-ghpages/node_modules/q/q.js:125:13)
    at process._tickCallback (internal/process/next_tick.js:112:11)
Done. Your build exited with 0.

this is my .travis.yml

language: node_js
sudo: false
node_js:
  - '9'

branches:
  only:
    - dev

before_script:
  - npm install -g @angular/cli
  - npm install -g angular-cli-ghpages

script:
  - ng build --prod

after_success:
  - echo "wangkanai.com" > dist/CNAME
  - ngh --branch=master

404s when loading on github

image

I have 404s on nearly all my build files and I can't figure out what setting I need to get these to resolve. My project source is here:

The offending page is here:

I'm obviously new to angular 2 and building to github. But from your wiki this seems like I'm doing something dumb. If anyone could be so kind as to point it I would really appreciate it.

fatal: could not read Username for 'https://github.com': No error

angular-cli-ghpages --no-silent
Cloning https://github.com/hamzahamidi/angular-sample.git into ..\AppData\Roaming\npm\node_modules\angular-cli-ghpages\node_modules\gh-pages.cache

Cleaning

Fetching origin

Checking out origin/gh-pages

Removing files

Copying files

Adding all

Committing

Pushing

An error occurred!
{ ProcessError: bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': No error

at ChildProcess.<anonymous> (C:\Users\Hamza\AppData\Roaming\npm\node_modules\angular-cli-ghpages\node_modules\gh-pages\lib\git.js:47:23)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

code: 128,
message: 'bash: /dev/tty: No such device or address\nerror: failed to execute prompt script (exit code 1)\nfatal: could not read Username for 'https://github.com\': No error\n',
name: 'ProcessError' }

Doesn't work for Angular 8

I tried to deploy a github page using angular-cli-ghpages for the new Angular 8 but it didn't work.

I got these errors in the console:

emiliapaz.github.io/:12 GET https://emiliapaz.github.io/agp/polyfills-es2015.e954256595c973372414.js net::ERR_ABORTED 404
emiliapaz.github.io/:9 GET https://emiliapaz.github.io/agp/styles.09e2c710755c8867a460.css net::ERR_ABORTED 404
2emiliapaz.github.io/:12 GET https://emiliapaz.github.io/agp/runtime-es2015.858f8dd898b75fe86926.js net::ERR_ABORTED 404

Deployed url!

I finished the steps and Successfully published! in the end , but I cannot find the deployed url ?!

Doent works for Ionic

Getting below error
The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli'
Error: The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli'
at Object. (C:\Users\Aj\AppData\Roaming\npm\node_modules@angular\cli\node_modules@ngtools\webpack\src\index.js:14:11)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (C:\Users\Aj\AppData\Roaming\npm\node_modules@angular\cli\tasks\eject.js:10:19)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)

Failed to load resource: the server responded with a status of 404

Hi mates,

I use first please excuse my English, it's not my native language..

npm -v
5.5.1

ng -v

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / β–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.5.2
Node: 8.9.1
OS: win32 x64
Angular: 5.0.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.2
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.36
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.2
@schematics/angular: 0.1.5
typescript: 2.4.2
webpack: 3.8.1

I use the Github repo to deploy my app.
I have no problem with localhost when I try to get my REST API, but I've the Promise error when I push with angular-cli-ghpages.

I resolve with a CNAME from my DNS.

Here's the app link :
[http://mean.negi.fr/]

click on the button "Se connecter" should load my Users List
[http://mean.negi.fr/#/panel]

The Github Repo:
[https://github.com/BlackNeo/gedprocedures]

Here's my code :

server.js

const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');

const api = require('./server/routes/api');

const port = 3000;

const app = express();

app.use(express.static(path.join(__dirname, 'dist')));

app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());

app.use('/api', api);

app.use('*', function allowCrossDomain(res, req, next) {
    res.header('Access-Control-Allow-Origin', 'example.com');
    res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
    res.header('Access-Control-Allow-Headers', 'Content-Type');
    next();
});

app.get('*', (req, res) => {
    res.sendFile(path.join(__dirname, 'dist/index.html'));
});

app.listen(port, function() {
    console.log("Server running on localhost :" + port);
});

server/routes/api.js

const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');

const api = require('./server/routes/api');

const port = 3000;

const app = express();

app.use(express.static(path.join(__dirname, 'dist')));

app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());

app.use('/api', api);

app.use('*', function allowCrossDomain(res, req, next) {
    res.header('Access-Control-Allow-Origin', 'example.com');
    res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
    res.header('Access-Control-Allow-Headers', 'Content-Type');
    next();
});

app.get('*', (req, res) => {
    res.sendFile(path.join(__dirname, 'dist/index.html'));
});

app.listen(port, function() {
    console.log("Server running on port :" + port);
});

server/models/user.js

`const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const usersSchema = new Schema ({
    username: String,
    password: String
});

module.exports = mongoose.model('users', usersSchema, 'users');

src/app/user.service.ts

const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const usersSchema = new Schema ({
    username: String,
    password: String
});

module.exports = mongoose.model('users', usersSchema, 'users');

src/app/app-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { LoginComponent } from './login/login.component';
import { PanelComponent } from './panel/panel.component';

const routes: Routes = [
  {path: '', pathMatch: 'full', component: HomeComponent},
  {path: 'panel', component: PanelComponent},
  {path: 'login', component: LoginComponent}
];

@NgModule({
  imports: [RouterModule.forRoot(routes, { useHash: true})],
  exports: [RouterModule],
  providers: []
})
export class AppRoutingModule { }`

src/app/app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';

import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { LoginComponent } from './login/login.component';
import { PanelComponent } from './panel/panel.component';
import { GedComponent } from './ged/ged.component';
import { FormsModule } from '@angular/forms';
import { ListComponent } from './list/list.component';
import { HttpModule } from '@angular/http';

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent,
    LoginComponent,
    PanelComponent,
    GedComponent,
    ListComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    FormsModule,
    HttpModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

src/app/panel/panel.component.html

import { Component, OnInit } from '@angular/core';
import { User } from '../user';
import { UserService } from '../user.service';

@Component({
  selector: 'app-panel',
  templateUrl: './panel.component.html',
  styleUrls: ['./panel.component.css'],
  providers : [UserService]
})
export class PanelComponent implements OnInit {

  users: Array<User>;

  selectedUser: User;

  isLogin: boolean;

  constructor(private _userService: UserService) { }

  ngOnInit() {
    this.isLogin = true;
    this._userService.getUsers()
      .subscribe(resUserData => this.users = resUserData);
  }

  onSelectUser(user: any) {
    this.selectedUser = user;
    this.isLogin = false;
    console.log(this.selectedUser);
  }
}

npm run deploy :
ng build --prod && angular-cli-ghpages --branch gh-pages

If someone can tell me what I'm doing wrong ?
Thanks

Image Asset Resolution Misses Repo Name

Following the instructions to publish to gh-pages for a specified repo REPOSITORY:

ng build --prod --base-href "https://USERNAME.github.io/REPOSITORY/"
ngh [OPTIONS]

leads to an issue with properly resolving image assets in components.

I.e. assume a png image is stored in the angular/cli assets folder. It is used in a component template:

<img src="/assets/some-image.png" class="img-responsive" />

While the assets folder is properly created in the gh-pages branch including the image, the image resolution in the Angular app on github.io fails. The resolution is attempted at:

https://USERNAME.github.io/assets/some-image.png

instead of

https://USERNAME.github.io/REPOSITORY/assets/some-image.png

Is there a way to address this issue as part of the publish process? As a hack, the image src can be prefixed through a manual commit to the gh-pages branch to wedge in the repo name. On a small repo like d3-ng2-demo this is viable, but certainly not in general.

Thanks in advance for suggestions addressing this issue.

github "Custom domain" settings are cleared after deployment

When using custom domains on github pages, the "custom domain" settings are cleared after building and publishing an angular app. After setting the custom domain in the settings manually again, the page would work, but it would be more convenient, if the custom domain settings would remain unchanged when deploying.

update

Found this: tschaub/gh-pages#213

Apparently, the solution is to add a CNAME file to the root directory which contains the custom domain in case of manual deployment. So I checked the local gh-pages branch which contains that file with the corresponding domain name. However, the remote origin/gh-pages branch doesn't contain any CNAME file for some reason. It seems like its not getting pushed for some reason during deployment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.