It is there a problem wh…

1 minute read

It is there a problem when using nx locally? I am running this, but apparently the flags are not passed: ```npm run nx g @nrwl/react:component Login –project=auth –export=true –flat=true –pascalCaseFiles=true –routing –style=sass Tue May 26 12:22:42 2020

> project@0.0.0 nx /Users/fernando/Code/experiments/project > nx “g” “@nrwl/react:component” “Login”

? What is the name of the project for this component? auth ? Should this component be exported in the project? Yes CREATE libs/auth/src/lib/login/login.scss (0 bytes) CREATE libs/auth/src/lib/login/login.spec.tsx (272 bytes) CREATE libs/auth/src/lib/login/login.tsx (257 bytes) UPDATE libs/auth/src/index.ts (117 bytes)```

Responses:

I think when you use npm run you need to preface your flags with --, so it would be npm run nx g @nrwl/react:component Login -- --projec=auth etc.

It used to be required at least, you don’t need it with yarn though, you can run yarn nx … Login --project=auth….

Right, I forgot about that one

Thanks!

Have you ever build a Docker file for an app using nx ? What is the story there? It is enough with a Dockerfile with some COPY s, right?

Yeah I have a Next.js app that I’m deploying in a container, my Dockerfile is basically like this

```FROM node:12

WORKDIR /usr/app

COPY dist/apps/APP_NAME /usr/app/.next

RUN yarn –production –pure-lockfile

COPY apps/APP_NAME/public /usr/app/public

CMD yarn run next start -p $PORT```

Works for me :smile:

you can also create a way to run the docker build if you’d like in workspace.json

I added this deploy command under my workspace.json > projects > APP_NAME > architect

"deploy": { "builder": "@nrwl/workspace:run-commands", "options": { "commands": [ { "command": "docker build -t $DOCKER_TAG ." }, { "command": "docker push $DOCKER_TAG" } ], "cwd": "./" }, } DOCKER_TAG is just an environment variable I pass to it and then I can run something like yarn build APP_NAME DOCKER_TAG=some-tag yarn deploy APP_NAME

That is a nice approach, I like it better because it is inside nx workflow.

Updated: