2

I have a frontend web app created using Angular 2 and TypeScript, and I just can't find a way to properly organize the build process.

Let's say I have this structure which I think is reasonable:

/
 - dist/   <-- transpiled .js files
 - src/    <-- .ts files
 - assets/
 - bower_components/
 - node_modules/
 - package.json
 - index.html

Question 1

Of course I'd like not to have the src folder on the production server. But when should I delete it, if I should? With a npm script? With a Grunt task? With a rm when creating a Docker image?

The same thing applies for package.json and Gruntfile.js.

Question 2

A similar issue comes from the node_modules folder: I use Browserify to bundle most of the dependencies of my app into a single file, so for example Angular becomes part of dist/bundle.js.

Should I delete node_modules on the production server, given that it isn't useful anymore? How?

For some reason I might use some modules that won't get included into the final bundle (e.g. because they're referenced from <script> tags): how do I know what to delete and what to keep?

1 Answer 1

2

I'm assuming that your TS/JS is entirely client-side (in-browser).

In that case, if your project contains no server-side code, I've seen a lot of projects use something like a www folder that represents the URL scheme of the website predeployment. Everything outside of www is only for development (src, node_modules, etc.). Keeps deploying simple :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.