Skip to content

Replace index.html, favicon.ico with fileReplacements option #2935

Closed

Description

Expected Behavior

fileReplacements would replace an index.html file if specified

Current Behavior

What is the current behavior?
File replacements only seems to work with .ts files.

Failure Information (for bugs)

Not sure where to find logs for this.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

npx create-nx-workspace@latest repro-workspace

nx add @nrwl/react

nx g @nrwl/react:app f5

Add apps/f5/src/environments/one-word-story.ts and apps/f5/src/one-word-story-index.html

update build to match this angular.json snippet

   "f5": {
      "root": "apps/f5",
      "sourceRoot": "apps/f5/src",
      "projectType": "application",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@nrwl/web:build",
          "options": {
            "outputPath": "dist/apps/f5",
            "index": "apps/f5/src/index.html",
            "main": "apps/f5/src/main.tsx",
            "polyfills": "apps/f5/src/polyfills.ts",
            "tsConfig": "apps/f5/tsconfig.app.json",
            "assets": ["apps/f5/src/favicon.ico", "apps/f5/src/assets"],
            "styles": ["apps/f5/src/styles.scss"],
            "scripts": [],
            "webpackConfig": "@nrwl/react/plugins/webpack"
          },
          "configurations": {
            "one-word-story": {
              "outputPath": "dist/apps/one-word-story",
              "fileReplacements": [
                {
                  "replace": "apps/f5/src/environments/environment.ts",
                  "with": "apps/f5/src/environments/one-word-story.ts"
                },
                {
                  "replace": "apps/f5/src/index.html",
                  "with": "apps/f5/src/one-word-story-index.html"
                },
             ]
           }
         }
       }
     }

nx run f5:build:one-word-story

If you can provide steps to reproduce from scratch, that would be enormously appreciated (i.e. where the first step is npx create-nx-workspace@latest repro-workspace)

Context

My use case is I'd like to generate different bundles for different customers without having to create a project for each customer. The differences between each customer's site is just index.ts, favicon.ico, and environment.ts.

Please provide any relevant information about your setup:

  @nrwl/cli : 8.11.2

Failure Logs

Not sure where to find these.

Other

Thanks for the great tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions