Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Build Config (dev mode) Used for Production Deployment in Vue 3, Vite, TypeScript Monorepo #27988

Open
1 of 4 tasks
rizypb opened this issue Sep 19, 2024 · 0 comments

Comments

@rizypb
Copy link

rizypb commented Sep 19, 2024

Current Behavior

I am trying to build and deploy a Vue 3, Vite, TypeScript project in an NX monorepo to serverless. However, despite running the production deployment command yarn nx run x-dashboard:deploy:production --no-cloud, NX still builds the project using the development configuration.

As a result, it uses the .env.development file instead of .env.production, which leads to incorrect environment variables (such as API paths) being set for the production build.

Expected Behavior

When running the deploy:production target, NX should use the production configuration, specifically reading from the .env.production file and building the project accordingly (with mode: production).

GitHub Repo

Unfortunately, this issue cannot be reproduced in the default https://github.com/nrwl/nx-examples repo as it's a custom configuration, but I am happy to provide more specific details from my project configuration if necessary.

Steps to Reproduce

  1. Create a Vue 3, Vite, TypeScript project inside an NX monorepo.
  2. Set up project.json with the following build and deploy configurations (as mentioned below):
 "build": {
   "executor": "@nx/vite:build",
   "outputs": ["{options.outputPath}"],
   "defaultConfiguration": "development",
   "options": {
     "outputPath": "dist/apps/x-dashboard",
     "skipTypeCheck": true,
     "assets": [
       {
         "input": "apps/x-dashboard/src/assets",
         "glob": "**/*.svg",
         "output": "assets"
       }
     ]
   },
   "configurations": {
     "development": {
       "mode": "development"
     },
     "production": {
       "mode": "production"
     }
   }
 },
 "deploy:development": {
   "executor": "nx:run-commands",
   "options": {
     "cwd": "apps/x-dashboard",
     "color": true,
     "command": "../../node_modules/.bin/serverless deploy --stage dev"
   },
   "dependsOn": [
     {
       "target": "deploy",
       "dependencies": true
     },
     {
       "target": "build"
     }
   ]
 },
 "deploy:production": {
   "executor": "nx:run-commands",
   "options": {
     "cwd": "apps/x-dashboard",
     "color": true,
     "command": "../../node_modules/.bin/serverless deploy --stage prod"
   },
   "dependsOn": [
     {
       "target": "deploy",
       "dependencies": true
     },
     {
       "target": "build"
     }
   ]
 }

  1. Run yarn nx run x-dashboard:deploy:production --no-cloud and notice that the build still uses the development mode and environment variables from .env.development.

Nx Report

Node           : 20.11.1
OS             : darwin-arm64
Native Target  : aarch64-macos
yarn           : 1.22.22

nx (global)        : 19.2.0
nx                 : 19.5.6
@nx/js             : 19.5.6
@nx/jest           : 19.5.6
@nx/linter         : 19.5.6
@nx/eslint         : 19.5.6
@nx/workspace      : 19.5.6
@nx/cypress        : 19.5.6
@nx/devkit         : 19.5.6
@nx/eslint-plugin  : 19.5.6
@nx/nest           : 19.5.6
@nx/node           : 19.5.6
@nrwl/tao          : 19.5.6
@nx/vite           : 19.5.6
@nx/vue            : 19.5.6
@nx/web            : 19.5.6
@nx/webpack        : 19.5.6
typescript         : 5.5.4

Failure Logs

No response

Package Manager Version

1.22.22

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

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

No branches or pull requests

1 participant