thinknimble/tn-spa-bootstrapper

Vue production build

Opened this issue · 3 comments

When setting up a vue production app without a staging app we run into the following issue:

vue-cli-service: not found

Vue CLI Service is and is meant to be a dev dependency from what I can tell, but with npm_config_production set to true in production, this causes the frontend app to not build.

I'm assuming that we haven't run into this bug before (as far as I'm aware) because we typically set up staging first and then production and we promote to production which doesn't require a rebuild of the frontend app.

However, I'm labelling this as an issue because we should be able to deploy our apps just for production as needed. My current workaround has been to just set npm_config_production=false in production which is not ideal.

A couple of approaches I tried:

  1. Setting vue-cli-service as a dependency. Caused a chain of other packages to need to be dependencies and we really don't want them to beSetting vue-cli-service as a dependency. Caused a chain of other packages to need to be dependencies and we really don't want them to be
  2. Removing the build command in package.json. Caused (unsurprisingly perhaps) the frontend to just not build/not build in the right folder. Not sure which one yet. Needs looking into further. I feel like removing the vue-cli-service dependency for the build would be the solution here

When we've looked at this before, we've concluded that setting NPM_CONFIG_PRODUCTION=false is safe in the prod environment. This enables Heroku to install devDependencies, but will still create a 'production' build, because NODE_ENV is set to 'production'.

https://thinknimble.slack.com/archives/G03GBBRC3/p1637266147072900?thread_ts=1637259568.071700&cid=G03GBBRC3

Before closing this I'd like to take a minute to understand the issue (or the symptom of a possible issue we are seeing).
Safety aside, we'd want to avoid the production build being bulkier than it needs to be (especially if we are install dev dependencies like Cypress...which is large)

Does our migration to vite make a difference (or solve) this issue ?