W01fw00d / cooking-with-amateurs

Cooking Recipes App. Uses Chemistry-UI
0 stars 0 forks source link

Fix Prod and Dev environments #56

Closed W01fw00d closed 2 years ago

W01fw00d commented 2 years ago

React-Hot-Loader and DevTools warning messages appear on js console on prod...

W01fw00d commented 2 years ago

This will fix the necessity of using the local "hack" in src\utils\request.ts

W01fw00d commented 2 years ago

https://reactjs.org/docs/optimizing-performance.html#use-the-production-build

W01fw00d commented 2 years ago

in package.json, are dependencies and devDependencies declared correctly?

W01fw00d commented 2 years ago

PROD build log warning:

WARNING in asset size limit and entrypoint size limit: The following asset(s) exceed the recommended size limit (244 KiB). This can impact web performance. Assets: bundle.js (728 KiB)

WARNING in webpack performance recommendations: You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application. For more info visit https://webpack.js.org/guides/code-splitting/

Removing the warning (but not the issue): https://stackoverflow.com/questions/49348365/webpack-4-size-exceeds-the-recommended-limit-244-kib

React code splitting and lazy loading: https://reactjs.org/docs/code-splitting.html

W01fw00d commented 2 years ago

Do we need to have separate server-back,js and server.js for env and prod? Maybe we can have same server and it can change its behavior depending on process.env.NODE_ENV

W01fw00d commented 2 years ago

nodemon vs node? We use both in package.json for different scripts.

nodemon just restarts the server anytime there's a change on development, similar to the react hot reload

W01fw00d commented 2 years ago

--- Issue

It seems the devDependencies get installed but then uninstalled?

remote: -----> Pruning devDependencies remote:
remote: > husky@4.2.1 preuninstall node_modules/husky remote: > node husky uninstall remote: remote: husky > Uninstalling git hooks remote: fatal: not a git repository (or any parent up to mount point /) remote: Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). remote: husky > Failed to uninstall remote: removed 1577 packages and audited 188 packages in 26.645s remote: found 2 vulnerabilities (1 moderate, 1 critical) remote: run npm audit fix to fix them, or npm audit for details

In this case, it seems that husky uninstall failed...

Also, Cypress is still installed on heroku server...

--- Investigation

Both dependencies and devDependencies are installed during Heroku process, but the they uninstall the devDependencies:

"Pruning devDependencies"

https://devcenter.heroku.com/changelog-items/1376

So, even if Cypress is installed, it should be removed afterwards.

But this makes the deployment process slower, and it's innecessary. We can fix that changing the Heroku config:

https://devcenter.heroku.com/articles/nodejs-support#package-installation

heroku config:set NPM_CONFIG_PRODUCTION=true YARN_PRODUCTION=true

W01fw00d commented 2 years ago

Caching: https://webpack.js.org/guides/caching/

W01fw00d commented 2 years ago

Can I move the webpack configs into a folder?

W01fw00d commented 2 years ago

Move link.sh into a "dev-tools" folder

W01fw00d commented 2 years ago

Set MONGODB_URL as a node env var and set it in https://dashboard.heroku.com/apps/cooking-with-amateurs/settings