Build your /dist
files on git commit!
How it works, if changes (diff) are detected in the staging area for a specific folder (i.e: /src
), build-add.sh
will trigger npm run build
and add the new/modified build files to that commit on-the-fly.
npm i -D pre-commit
Modify your package.json
{
"scripts": {
"start": "webpack --config webpack.config.dev.js",
"build": "webpack --config webpack.config.prod.js",
"build:add": "bash ./build-add.sh",
},
"pre-commit": [
"build:add"
]
}
Edit your paths in build-add.sh
SRC_PATH="src/" # The source, Luke
DIST_PATH="dist/" # The path where distribution files are generated
As usual,
git commit
If you need to skip the build process, simply pass -n
(or --no-verify
) flag. i.e:
git commit -n -m "WIP Done that"