W01fw00d / cooking-with-amateurs

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

Optimize Heroku env #75

Closed W01fw00d closed 3 years ago

W01fw00d commented 3 years ago

https://devcenter.heroku.com/articles/troubleshooting-node-deploys

W01fw00d commented 3 years ago

Issue 1: When doing deploy in Heroku with:

NPM_CONFIG_PRODUCTION = true
YARN_PRODUCTION = true

We get a crash on build phase:

cooking-with-amateurs@1.1.5 build /tmp/build_08f1cd48
remote:        > webpack --config webpack/webpack.prod.js
remote:
remote: [webpack-cli] Error: Cannot find module 'acorn'

Current workaround:

Removing NPM_CONFIG_PRODUCTION and YARN_PRODUCTION from ConfigFiles, so Heroku works by default on Production but installing devDependencies and then uninstalling them after build.

Idea for solution:

Ideally, we want to make Heroku work on NPM_CONFIG_PRODUCTION = true to speed up the deployment process (it avoids installing devDependencies altogether). Maybe there's a devDependencies that is needed in dependencies for Heroku? (in local the crash was not reproduced when running npm install --only=prod)

https://dashboard.heroku.com/apps/cooking-with-amateurs/settings

W01fw00d commented 3 years ago

Issue 2:

We are forced to maintain server.js, webpack.common.js and webpack.dev.js in root because when moving them to their own folders changing __dirname by __dirname.replace('\\folder', '') breaks Heroku but not local.

This might be related to a OS difference, as local is Windows and Heroku might be linux server.

Idea: find a way to solve this for both local and heroku envs;

debug result: __dirname in heroku is: '/app'; in local it's C:\projects\cooking-with-amateurs. A difference in / and \; that might be the issue. Need to direct to root without relying in those separators that might change depending if route is absolute or relative I think.

W01fw00d commented 3 years ago

Look for remaining TODOs set to test Heroku

W01fw00d commented 3 years ago

Idea:

When the server is on dev mode, it should not allow access to localhost:5000/#/list, that's only needed for prod.

Make the server ignore index.html in that case?