nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.17k stars 2.3k forks source link

Nx serve doesn't serve assets from libs anymore #10859

Closed femi-ojemuyiwa-aa closed 2 years ago

femi-ojemuyiwa-aa commented 2 years ago

Sorry it's been a long day

libs with assets

app with project.json unser assets: { "glob": "*/", "input": "libs/project-name/src/assets/fonts", "output": "/assets/fonts/" }

works with build into dist folder 100% serve throws 404

versions

"dependencies": { "@angular/animations": "14.0.2", "@angular/common": "14.0.2", "@angular/compiler": "14.0.2", "@angular/core": "14.0.2", "@angular/forms": "14.0.2", "@angular/platform-browser": "14.0.2", "@angular/platform-browser-dynamic": "14.0.2", "@angular/router": "14.0.2", "@ngxs/store": "^3.7.3", "@nrwl/angular": "14.3.5", "rxjs": "~7.4.0", "storybook": "^6.5.9", "tslib": "^2.0.0", "zone.js": "~0.11.4" }, "devDependencies": { "@angular-devkit/build-angular": "14.0.0", "@angular-eslint/eslint-plugin": "13.2.1", "@angular-eslint/eslint-plugin-template": "13.2.1", "@angular-eslint/template-parser": "13.2.1", "@angular/cli": "~14.0.0", "@angular/compiler-cli": "14.0.2", "@angular/language-service": "14.0.2", "@nrwl/cli": "14.3.5", "@nrwl/cypress": "14.3.5", "@nrwl/eslint-plugin-nx": "14.3.5", "@nrwl/jest": "14.3.5", "@nrwl/linter": "14.3.5", "@nrwl/storybook": "14.3.5", "@nrwl/workspace": "14.3.5", "@storybook/addon-a11y": "^6.5.7", "@storybook/addon-essentials": "6.5.4", "@storybook/addon-storyshots": "^6.5.7", "@storybook/angular": "6.5.4", "@storybook/builder-webpack5": "^6.5.4", "@storybook/core-server": "6.5.4", "@storybook/manager-webpack5": "^6.5.4", "@types/jest": "27.4.1", "@types/mdx": "^2.0.2", "@types/node": "16.11.7", "@typescript-eslint/eslint-plugin": "5.24.0", "@typescript-eslint/parser": "5.24.0", "bootstrap": "^5.1.3", "cypress": "^9.1.0", "eslint": "8.15.0", "eslint-config-prettier": "8.1.0", "eslint-plugin-cypress": "^2.10.3", "eslint-plugin-storybook": "^0.5.12", "gulp": "^4.0.2", "gulp-imagemin": "^7.1.0", "htmlhint": "^1.1.4", "jest": "27.5.1", "jest-junit": "13.2.0", "jest-preset-angular": "11.1.2", "json-to-scss": "^1.6.2", "nx": "14.3.5", "prettier": "2.6.2", "storybook-addon-designs": "^6.2.1", "ts-jest": "27.1.4", "ts-node": "10.8.0", "typescript": "4.7.2", "webpack": "^5.64.0" }

AgentEnder commented 2 years ago

Can you post the rest of your project.json? The implementation of assets depends on which executor is running,

femi-ojemuyiwa-aa commented 2 years ago

Can you post the rest of your project.json? The implementation of assets depends on which executor is running,

{
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
  "projectType": "application",
  "sourceRoot": "apps/myapp/src",
  "prefix": "ukb",
  "targets": {
    "build": {
      "executor": "@angular-devkit/build-angular:browser",
      "outputs": ["{options.outputPath}"],
      "options": {
        "outputPath": "dist/apps/myapp",
        "index": "apps/myapp/src/index.html",
        "main": "apps/myapp/src/main.ts",
        "polyfills": "apps/myapp/src/polyfills.ts",
        "tsConfig": "apps/myapp/tsconfig.app.json",
        "inlineStyleLanguage": "scss",
        "assets": [
          "apps/myapp/src/favicon.ico",
          "apps/myapp/src/assets",
          {
            "glob": "**/*",
            "input": "libs/core-ui/src/assets/fonts",
            "output": "/assets/fonts/"
          },
          {
            "glob": "**/*",
            "input": "libs/core-ui/src/assets/icons",
            "output": "/assets/icons/"
          }
        ],
        "styles": ["apps/myapp/src/styles.scss"],
        "scripts": [],
        "baseHref": "/sales/myapp/"
      },
      "configurations": {
        "production": {
          "budgets": [
            {
              "type": "initial",
              "maximumWarning": "500kb",
              "maximumError": "1mb"
            },
            {
              "type": "anyComponentStyle",
              "maximumWarning": "2kb",
              "maximumError": "4kb"
            }
          ],
          "fileReplacements": [
            {
              "replace": "apps/myapp/src/environments/environment.ts",
              "with": "apps/myapp/src/environments/environment.prod.ts"
            }
          ],
          "scripts": [],
          "outputHashing": "all",
          "optimization": {
            "scripts": true,
            "styles": {
              "minify": true,
              "inlineCritical": false
            },
            "fonts": true
          }
        },
        "development": {
          "buildOptimizer": false,
          "optimization": false,
          "vendorChunk": true,
          "extractLicenses": false,
          "sourceMap": true,
          "namedChunks": true
        }
      },
      "defaultConfiguration": "production"
    },
    "serve": {
      "executor": "@angular-devkit/build-angular:dev-server",
      "configurations": {
        "production": {
          "browserTarget": "myapp:build:production",
          "proxyConfig": "apps/myapp/src/proxy.config.json"
        },
        "development": {
          "browserTarget": "myapp:build:development",
          "proxyConfig": "apps/myapp/src/proxy.config.json"
        }
      },
      "defaultConfiguration": "development"
    },
    "extract-i18n": {
      "executor": "@angular-devkit/build-angular:extract-i18n",
      "options": {
        "browserTarget": "myapp:build"
      }
    },
    "lint": {
      "executor": "@nrwl/linter:eslint",
      "options": {
        "lintFilePatterns": ["apps/myapp/**/*.ts", "apps/myapp/**/*.html"]
      }
    },
    "test": {
      "executor": "@nrwl/jest:jest",
      "outputs": ["coverage/apps/myapp"],
      "options": {
        "jestConfig": "apps/myapp/jest.config.ts",
        "passWithNoTests": true
      }
    }
  },
  "tags": []
}
leosvelperez commented 2 years ago

hey @femi-ojemuyiwa-aa!

Could you share a repo where this issue can be reproduced? I can't reproduce it.

femi-ojemuyiwa-aa commented 2 years ago

hey @femi-ojemuyiwa-aa!

Could you share a repo where this issue can be reproduced? I can't reproduce it.

Thanks so much for taking the time. Please close the ticket as we will be removing nx and decoupling repos due to other business reasons.

I'm guessing the migrate script we ran may have thrown something out, but for now will not pursue these further.

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.