quasarframework / quasar-cli

[DEPRECATED, <= 0.17) Quasar Framework - CLI
https://quasar.dev
MIT License
202 stars 50 forks source link

[Bug] quasar build deletes previous dist folder before build is complete #165

Closed rossity closed 6 years ago

rossity commented 6 years ago

When running quasar build, the current process is

  1. delete dist/<build-type>
  2. build project
  3. place build files in dist/<build-type>

I'm running quasar build as part of the deployment process on my server so that results in a large gap of time where the server can't find any files for the project. Would it be possible to change the process so it goes:

  1. build project
  2. delete dist/<build-type>
  3. place build files in dist/<build-type>

That way there is virtually no downtime on the production app!

rossity commented 6 years ago

Would it be as simple as moving this line into the finalize promise?

rstoenescu commented 6 years ago

Hi,

Good way: build > copy dist folder somewhere > serve from there Bad way: build (so dist folder gets generated) > delete dist > ending up with no dist folder :)

PS: the dist/* folders can be standalone by themselves.

rossity commented 6 years ago

@rstoenescu thanks for the response! I didn't mean delete the dist folder, I just meant is it possible to move the artifacts.clean(outputFolder) until just before the the build files are placed in the output folder? It's nice to be able to serve from the /dist without having to write any copy scripts!

mstaack commented 6 years ago

@rossity i would prefer buidling the application in a vm/container/local.... and then publish that build (dist folder) to production.

rossity commented 6 years ago

@mstaack I use scripts to automatically push my code to the production server whenever I push to the master branch of my version control. Trying to automate it as much as possible! I don't like including the /dist folder (or built files) in version control which is why I don't build locally.

mstaack commented 6 years ago

@rossity ok... sounds good ;)

rossity commented 6 years ago

Quick and dirty solution for anyone who runs across this

  1. Create a folder in project named scripts with a file named transfer.js
    
    const fs = require('fs-extra')

const folder = process.argv[2]

async function execute() { try { await fs.emptyDir('./public') console.log('Deleted public folder contents!') await fs.copy(./dist/${folder}, './public', { overwrite: true }) console.log('Installed new files in public folder!') } catch (err) { console.error(err) } }

execute()


2. In `package.json`
```js
"scripts": {
    "transfer": "node scripts/transfer.js"
  }
  1. run yarn transfer <folder-name> with <folder-name> being whatever build the project is: spa-mat, 'pwa-ios` etc.

Tweak it however you like but that worked well for me and is pretty fast even for a large project, thanks @rstoenescu for the idea!