Autodesk-Forge / forge-react-boiler.nodejs

React and Node.js boilerplate examples collection: Provides a boilerplate project for using the Forge APIs in a modern React + Node.js web application
MIT License
54 stars 24 forks source link

dev dependencies #2

Closed torjuss closed 7 years ago

torjuss commented 7 years ago

Hi, and thanks for a great boilerplate!

I building an application based on this boilerplate and have set up deployment of the project to an Azure web app. I wanted the web app to handle the production build (the "dist" folder) so that "dist" doesn't have to be included in my git source control. I managed to build the project on the Azure server, but only when I forced installation of all devDependencies. The default behaviour in Azure is to skip dev dependencies when the environment is set to production. So I am wondering why so many of the dependencies are listed as devDependencies. Shouldn't packages like bootstrap, jquery and react be regular dependencies?

leefsmp commented 7 years ago

yeah... I have the same problem when deploying on heroku, so my workaround was to set NPM_CONFIG_PRODUCTION=false, which forces NPM to run in development but will build the App with the current env, i.e production. I don't have much experience with Azure so I can't tell you if there is a similar flag or approach, I would look in stackoverflow as somebody most likely hit the same issue.

Another workaround would be to move all packages into regular dependencies for your project, but that kind of defeats the purpose of splitting dev vs regular. I made this choice to have a cleaner separation for people who have a different deployment mechanism and may not want to install all deps which are only used to build the frontend.

Sorry for the inconvenience. I'm going to close this, but feel free to update the thread if you find a Azure-specific workaround, thanks!

torjuss commented 7 years ago

Okay, I will just stick to my workaround then and use a custom deployment (.cmd) script in Azure where I override the default behaviour by replacing "npm install --production" (or "npm install --only=prod") with just "npm install". I finally found someone else using a similar apporach in this article. I am still a little confused about why e.g. jquery is a dev dependency, but it doesn't really matter as long as my deployment works. 👍

leefsmp commented 7 years ago

The dev dependencies are typically the packages required to build the UI, such as react and jquery. The regular dependencies are the ones needed to run the node server, assuming the dist/ has been generated previously.

torjuss commented 7 years ago

When you look at it that way it makes more sense. Thank you!