DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

Building JavaScript assets offline, before deploying to the web server

I have always wondered why I have to run yarn build scripts online on Heroku / Netlify / Now.sh; which takes time, does not guarantee to succeed and HTML / JavaScript / CSS are cross platform anyway.

Long time ago, I have found gh-pages and wrote a blog about it -- https://www.polvcode.dev/post/2019/08/gh-pages -- which is mostly about publishing to GitHub Pages, and Heroku.

However, there are problems with GitHub Pages; namely, new pages doesn't always update promptly after repeated deployment. There are these kind of problems in Heroku / Netlify / Now.sh.

Lately, I have one another way for Netlify, which is Netlify CLI deploy, so I just pust "deploy": "yarn build && netlify deploy --dir dist" in my package.json. Netlify also offers a way to test a real website online (with hash, so that the name doesn't collide).

So, back to the real question, why do I have to run build script for static JavaScript / CSS / HTML assets online, again?

Top comments (1)

Collapse
 
anwar_nairi profile image
Anwar

Maybe because these services do not assume which technology you use to produce the files you host.

One can use Pug for templating, others can choose Gridsome (with Pug for the components 🤔), ones can use Angular, ones can use nothing, ... So the complexity of the project can be such that these services would put an impressive amount of time trying to cope with all the possible builds.

So instead, I think they legitimately let the developer handle this complexity.

Honestly, I think it is good, because you can handle very complex and precise use case on your own, without having another layer of conversion, in which you are not sure your specific galactic build will be supported by these providers.