Minimize js and css files in docker build #31
@ -5,11 +5,16 @@ WORKDIR /usr/src/app
|
|||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
RUN npm install uglifycss -g
|
||||||
|
RUN npm install uglify-js -g
|
||||||
|
|
||||||
COPY Webservice Webservice
|
COPY Webservice Webservice
|
||||||
COPY public public
|
COPY public public
|
||||||
COPY data data
|
COPY data data
|
||||||
|
COPY minimize.sh minimize.sh
|
||||||
|
|
||||||
|
RUN chmod +x minimize.sh
|
||||||
|
RUN ./minimize.sh
|
||||||
RUN sed -i "s/DATE_TO_BE_REPLACED/$(date +%s)/" public/index.html
|
RUN sed -i "s/DATE_TO_BE_REPLACED/$(date +%s)/" public/index.html
|
||||||
RUN sed -i "s/COMMIT_TO_BE_REPLACED/GitHub: $(git ls-remote https://github.com/H4CK3R-01/Projektmanagement-Game refs/heads/main | awk '{print $1;}' | cut -c1-7)/" public/index.html
|
RUN sed -i "s/COMMIT_TO_BE_REPLACED/GitHub: $(git ls-remote https://github.com/H4CK3R-01/Projektmanagement-Game refs/heads/main | awk '{print $1;}' | cut -c1-7)/" public/index.html
|
||||||
RUN sed -i "s/COMMIT_LINK_TO_BE_REPLACED/https\:\/\/github.com\/H4CK3R-01\/Projektmanagement-Game\/commit\/$(git ls-remote https://github.com/H4CK3R-01/Projektmanagement-Game refs/heads/main | awk '{print $1;}')/" public/index.html
|
RUN sed -i "s/COMMIT_LINK_TO_BE_REPLACED/https\:\/\/github.com\/H4CK3R-01\/Projektmanagement-Game\/commit\/$(git ls-remote https://github.com/H4CK3R-01/Projektmanagement-Game refs/heads/main | awk '{print $1;}')/" public/index.html
|
||||||
|
20
minimize.sh
Executable file
20
minimize.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
which uglifycss
|
||||||
|
|
||||||
|
#minification of JS files
|
||||||
|
cd public/js || exit
|
||||||
|
for f in *.js; do
|
||||||
|
case "$f" in
|
||||||
|
*"min.js") ;;
|
||||||
|
*) uglifyjs "$f" > "${f%.js}".min.js && sed -i "s/$f/${f%.js}.min.js/" ../index.html
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
#minification of CSS files
|
||||||
|
cd ../css || exit
|
||||||
|
for f in *.css; do
|
||||||
|
case "$f" in
|
||||||
|
*"min.css") ;;
|
||||||
|
*) uglifycss --output "${f%.css}".min.css "$f" && sed -i "s/$f/${f%.css}.min.css/" ../index.html
|
||||||
|
esac
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user