insomnia/scripts/build.sh
2016-10-11 14:06:25 -07:00

36 lines
732 B
Bash

#!/bin/bash
#? Package the app
set -e
NODE_VERSION="$(node --version)"
if [ "$NODE_VERSION" != "v6.4.0" ]; then
echo "ERROR: Node version should be 6.4.0, got $NODE_VERSION instead"
exit 1
fi
BUILD_DIR='./build'
echo "-- REMOVING DIST FOLDER --"
if [ -d "$BUILD_DIR" ]; then
rm -r "$BUILD_DIR"
fi
echo "-- BUILDING PRODUCTION APP --"
cross-env NODE_ENV=production webpack --config ./webpack/webpack.config.production.babel.js
echo "-- COPYING REMAINING FILES --"
# Copy package JSON
cp app/package.json "$BUILD_DIR"
# Copy some things
cp -r app/external assets/* app/main.js "$BUILD_DIR/"
echo "-- INSTALLING PACKAGES --"
cd "$BUILD_DIR"/
cross-env NODE_ENV=production npm install
echo "-- BUILD COMPLETE --"