-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·81 lines (60 loc) · 2.74 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
set -euo pipefail
# Colors
yellow='\033[1;33m' # Yellow
nc='\033[0m' # No Color
echo -e "${yellow}"
echo -e "|--------------------------------------------------------|"
echo -e "| Building the application with Bash and Webpack |"
echo -e "|--------------------------------------------------------|"
OS=$(uname -a)
echo -e "\n Building on OS: ${OS}"
echo -e "\n 1. Cleaning up & copying files"
# Removing the dist folder
echo -e " -> Removing the dist folder"
rm -rf ./dist
# Creating dist directories
echo -e " -> Creating the dist folder structure"
mkdir -p ./dist/css ./dist/img ./dist/js ./dist/fonts
# Copy bootstrap.min.js and klaro-no-css.js
echo -e " -> Copying bootstrap.min.js to dist/js folder"
cp -R ./node_modules/bootstrap/dist/js/bootstrap.min.js ./dist/js
cp -R ./public/js/klaro-no-css.js ./dist/js
# Copy all images
echo -e " -> Copying all images to dist/img folder"
cp -R ./public/img/. ./dist/img
# Copy all fonts
echo -e " -> Copying all fonts to dist/fonts folder"
cp -R ./public/fonts/. ./dist/fonts
# Copy all CSS
echo -e " -> Copying all CSS to dist/css folder"
cp -R ./public/css/. ./dist/css
# Only production
if [ $1 == "prod" ]; then
# Run webpack build on the vendor.js file and put the optimized file in the /dist folder.
echo -e "${yellow}\n 2. Transpiling kth-bootstrap.scss and put it /dist/css folder${nc}"
npm run sass-prod
# Run webpack build on the vendor.js file and put the optimized file in the /dist folder.
echo -e "${yellow}\n 3. Parcing all js files and putting them in the /dist/js folder${nc}"
npm run babel-js-prod
# Run webpack build on the vendor.js file and put the optimized file in the /dist folder.
# echo -e "${yellow}\n 3. Parcing all js files and putting them in the /dist/js folder${nc}"
# npm run webpack
# Run create-zip and create the kth-style-scss.zip package and put it in the dist folder
echo -e "${yellow}\n 4. Creating the kth-style-scss.zip package and putting it in the /dist folder${nc}"
npm run create-zip
ls -lR dist
if [[ ! -s dist/css/kth-bootstrap.css || ! -s dist/kth-style-scss.zip || ! -s dist/js/backtotop.js || ! -s dist/js/menus.js || ! -s dist/js/vendor.js ]]; then
echo >&2 "Some files are missing, failing..."
exit 1
fi
fi
# Only run webpack watch in development
if [ $1 == "dev" ]; then
# Run webpack build on the vendor.js file and put the optimized file in the /dist folder.
echo -e "${yellow}\n 2. Transpiling kth-bootstra.scss and put it /dist/css folder${nc}"
npm run sass-dev
# Run webpack build on the vendor.js file and put the optimized file in the /dist folder.
echo -e "${yellow}\n 3. Parcing all js files and putting them in the /dist/js folder${nc}"
npm run webpack-watch
fi