From 88c19eb45e90d5a8495f57b7337ec17cbc9dce5c Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sun, 25 Feb 2024 11:45:00 +0100 Subject: [PATCH] Feature/restructure copy assets nx target (#3045) * Restructure copy-assets Nx target * Update changelog --- CHANGELOG.md | 6 ++++++ apps/api/project.json | 24 ++++++++++++++++++++---- apps/client/project.json | 19 +++++++++++-------- package.json | 7 +++---- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f287cb1d..a9bb1995f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Changed + +- Restructured the `copy-assets` `Nx` target + ## 2.56.0 - 2024-02-24 ### Changed diff --git a/apps/api/project.json b/apps/api/project.json index f3c8bd1e0..fb59eb70f 100644 --- a/apps/api/project.json +++ b/apps/api/project.json @@ -9,12 +9,12 @@ "build": { "executor": "@nx/webpack:webpack", "options": { - "outputPath": "dist/apps/api", + "compiler": "tsc", + "deleteOutputPath": false, "main": "apps/api/src/main.ts", - "tsConfig": "apps/api/tsconfig.app.json", - "assets": ["apps/api/src/assets"], + "outputPath": "dist/apps/api", "target": "node", - "compiler": "tsc", + "tsConfig": "apps/api/tsconfig.app.json", "webpackConfig": "apps/api/webpack.config.js" }, "configurations": { @@ -33,6 +33,22 @@ }, "outputs": ["{options.outputPath}"] }, + "copy-assets": { + "executor": "nx:run-commands", + "options": { + "commands": [ + { + "command": "shx mkdir -p dist/apps/api/assets/locales" + }, + { + "command": "shx cp -r apps/api/src/assets/* dist/apps/api/assets" + }, + { + "command": "shx cp -r apps/client/src/locales/* dist/apps/api/assets/locales" + } + ] + } + }, "serve": { "executor": "@nx/js:node", "options": { diff --git a/apps/client/project.json b/apps/client/project.json index 4eb03df3c..91370a184 100644 --- a/apps/client/project.json +++ b/apps/client/project.json @@ -13,13 +13,13 @@ "build": { "executor": "@nx/angular:webpack-browser", "options": { + "deleteOutputPath": false, "localize": true, "outputPath": "dist/apps/client", "index": "apps/client/src/index.html", "main": "apps/client/src/main.ts", "polyfills": "apps/client/src/polyfills.ts", "tsConfig": "apps/client/tsconfig.app.json", - "assets": [], "styles": [ "apps/client/src/assets/fonts/inter.css", "apps/client/src/styles/theme.scss", @@ -108,13 +108,19 @@ "options": { "commands": [ { - "command": "shx mkdir -p dist/apps/client" + "command": "shx mkdir -p dist/apps/client/.well-known" }, { - "command": "shx cp -r apps/client/src/assets dist/apps/client" + "command": "shx mkdir -p dist/apps/client/assets" }, { - "command": "shx cp -r apps/client/src/assets/.well-known dist/apps/client" + "command": "shx mkdir -p dist/apps/client/ionicons" + }, + { + "command": "shx cp -r apps/client/src/assets/* dist/apps/client/assets" + }, + { + "command": "shx cp -r apps/client/src/assets/.well-known/* dist/apps/client/.well-known" }, { "command": "shx cp apps/client/src/assets/favicon.ico dist/apps/client" @@ -128,9 +134,6 @@ { "command": "shx cp apps/client/src/assets/site.webmanifest dist/apps/client" }, - { - "command": "shx cp -r apps/client/src/locales dist/apps/api/assets" - }, { "command": "shx cp node_modules/ionicons/dist/index.js dist/apps/client" }, @@ -138,7 +141,7 @@ "command": "shx cp node_modules/ionicons/dist/ionicons.js dist/apps/client" }, { - "command": "shx cp -r node_modules/ionicons/dist/ionicons dist/apps/client/ionicons" + "command": "shx cp -r node_modules/ionicons/dist/ionicons/* dist/apps/client/ionicons" }, { "command": "shx cp CHANGELOG.md dist/apps/client/assets" diff --git a/package.json b/package.json index 414623571..f20df1f90 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,7 @@ "affected:lint": "nx affected:lint", "affected:test": "nx affected:test", "angular": "node --max_old_space_size=32768 ./node_modules/@angular/cli/bin/ng", - "build:dev": "nx run api:build && nx run client:build && nx run client:copy-assets && yarn replace-placeholders-in-build", - "build:production": "nx run api:build:production && nx run client:build:production && nx run client:copy-assets && yarn replace-placeholders-in-build", + "build:production": "nx run api:copy-assets && nx run api:build:production && nx run client:copy-assets && nx run client:build:production && yarn replace-placeholders-in-build", "build:storybook": "nx run ui:build-storybook", "database:format-schema": "prisma format", "database:generate-typings": "prisma generate", @@ -41,7 +40,7 @@ "start": "node dist/apps/api/main", "start:client": "nx run client:copy-assets && nx run client:serve --configuration=development-en --hmr -o", "start:production": "yarn database:migrate && yarn database:seed && node main", - "start:server": "nx run api:serve --watch", + "start:server": "nx run api:copy-assets && nx run api:serve --watch", "start:storybook": "nx run ui:storybook", "test": "yarn test:api && yarn test:common", "test:api": "npx dotenv-cli -e .env.example -- nx test api", @@ -49,7 +48,7 @@ "test:single": "nx run api:test --test-file portfolio-calculator-novn-buy-and-sell.spec.ts", "ts-node": "ts-node", "update": "nx migrate latest", - "watch:server": "nx run api:build --watch", + "watch:server": "nx run api:copy-assets && nx run api:build --watch", "watch:test": "nx test --watch", "workspace-generator": "nx workspace-generator" },