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

Typescript integration #39

Open
diegolaciar opened this issue Oct 31, 2018 · 5 comments
Open

Typescript integration #39

diegolaciar opened this issue Oct 31, 2018 · 5 comments

Comments

@diegolaciar
Copy link

Hi Bret,

I'm using typescript with node.

the command 'npm run build' generate the compiled sources on 'dist' folder.

I want to ask you how would you update the Dockerfile to use a prepiler as typescript or babel with node? What is best practice on this case?

Thanks,
Diego

@BretFisher
Copy link
Owner

  1. add that command to the Dockerfile in a RUN line after code is copied in
  2. add that to nodemon config so it runs on every node restart for local development

@BretFisher
Copy link
Owner

Good question, so this would be a good example for this repo so I'll add it as a feature request.

@focux
Copy link

focux commented Jan 8, 2019

I'm also using Typescript but I'm having a problem with my IDE (VSCode). For types to work, it needs to load @types files but when VSCode try to find the types inside node_modules folder, it can't find it because that folder is inside the container. Is there any work around to make this work?

@joebowbeer
Copy link
Contributor

@focux Compare with Microsoft recipe, which installs in host:

https://github.com/Microsoft/vscode-recipes/tree/master/Docker-TypeScript

@BretFisher
Copy link
Owner

@focux in cases where you need host tools to see node_modules, then you could:

  1. Just run npm install on host purely for tools like VSCode. If you’re keeping container node_modules in container like this repo example shows, they shouldn’t conflict.
  2. Move to a node_modules model where you are bind-mounting the app directory and using the node_modules below it. This means you’d change compose yaml to not hide host node_modules and you’d need to then “initialize” the host node_modules dir from inside the container with something like docker-compose run node npm i before doing a docker-compose up. This way you simplify the node_modules config on both host and container and VSCode will work, but you loose the advantage of having node_modules in container on a different path, which means you have to be careful not to ever do a npm install from host.

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

4 participants