In a previous post, I demonstrated how to set up Netlify with a static website. However, we skimmed over two fields:
Publish directory and
Build command suggests, you can run commands on every code change before deploying the site. This is important if your website requires pre-processing such as CSS minification or a bundler call. Some of the examples provided by Netlify at the time of writing are:
However, what’s undocumented is that you can actually use
npm commands as your build command, such as
npm run build. This is likely because Netlify relies on a Node.js back-end, although there are no documentation to support this.
Try It Yourself
I have a a sample React.js application that has the following Netlify configurations, defined inside a
[build] base = "." publish = "build" command = "npm run build"
This file tells Netlify to run
npm run build before every deployment, and that
npm run build will put the bundled static files into the
Simply fork the repo, or click on the
Deploy to netlify button to get started.
“Tech I Use” is a series of blog posts that highlights some of the technologies I use for personal projects....