Skip to content

Instantly share code, notes, and snippets.



Last active Mar 2, 2017
What would you like to do?
ember-cli + Rails build
# Based on
# for (( i = 0; i < 17; i++ )); do echo "$(tput setaf $i)This is ($i) $(tput sgr0)"; done
function printMessage {
color=$(tput setaf $1)
reset=$(tput sgr0)
echo -e "${color}${message}${reset}"
function boldMessage {
color=$(tput setaf $1)
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"

This comment has been minimized.

Copy link

@ballPointPenguin ballPointPenguin commented Jun 15, 2014

This is extremely helpful. I made some modifications for my file structure, which is inspired by, 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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment