Last active
March 2, 2017 13:45
-
-
Save abuiles/5c281123fc41e6b988e3 to your computer and use it in GitHub Desktop.
ember-cli + Rails build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Based on https://github.com/knomedia/ember-cli-rails/blob/master/build.sh | |
# for (( i = 0; i < 17; i++ )); do echo "$(tput setaf $i)This is ($i) $(tput sgr0)"; done | |
function printMessage { | |
color=$(tput setaf $1) | |
message=$2 | |
reset=$(tput sgr0) | |
echo -e "${color}${message}${reset}" | |
} | |
function boldMessage { | |
color=$(tput setaf $1) | |
message=$2 | |
reset=$(tput sgr0) | |
echo -e "${color}*************************************${reset}" | |
echo -e "${color}${message}${reset}" | |
echo -e "${color}*************************************${reset}" | |
} | |
#echo -e "${color}Building Ember app${reset}" | |
boldMessage 4 "Building Ember app" | |
cd client | |
ember build --environment production | |
cd ../ | |
rm -rf public/ember-assets | |
printMessage 4 "Copying ember build files to rails" | |
cp -r client/dist/ public/ | |
printMessage 4 "Swaping assets dir for ember-assets" | |
mv public/assets public/ember-assets | |
printMessage 4 "Replacing references s/assets/ember-assets/ in public/index.html" | |
sed -i .bck s/assets/ember-assets/ public/index.html | |
printMessage 4 "inserting csrf_meta_tags in head" | |
sed -i .bck 's/<\/head>/<%= csrf_meta_tags %>&/' public/index.html | |
printMessage 4 "inserting yield in body" | |
sed -i .bck 's/<body>/&<%= yield %>/' public/index.html | |
printMessage 4 "Replacing application.html.erb with index.html" | |
mv public/index.html app/views/layouts/application.html.erb | |
printMessage 4 "Cleaning Up" | |
rm -rf public_bk/ | |
rm public/index.html.bck | |
boldMessage 4 "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is extremely helpful. I made some modifications for my file structure, which is inspired by http://reefpoints.dockyard.com/2014/05/31/building-an-ember-app-with-rails-part-4.html, plus I had to remove the space between -i and .bck (maybe an oh-my-zsh or even Ubuntu thing??), and a couple other nit-pickings.
In case this is helpful: https://github.com/ballPointPenguin/fcc/blob/master/build.sh