Ember CLI app inside the Rails engine

I am creating a Rails engine that has a /admin route. I would like to create this admin interface using the Ember CLI.

I know that rails will automatically precompile any static JS / CSS that live in my lib engine and load them only when the parent application mounts my engine and visits this route. However, I would like to use the Ember CLI to create an admin interface.

What would be a good way to do this? Ideally, I would like Ember CLI to be built from a repo.

+7
ruby-on-rails ember-cli rails-engines
source share
1 answer

My solution was to keep the assembly of the Ember CLI application in the engine.

I wrote a rake task that runs ember build and moves the static dist to the public/my-engine directory and combines these public static assets with the shared folder of the host application.

Here is the task of our specific project :

 namespace :admin do task :build do Dir.chdir('admin') do sh 'ember build --environment=production' end # Copy the dist to public FileUtils.rm_r 'public/front_end_builds' FileUtils.mv 'admin/dist', 'public/front_end_builds' # Move the index out of public FileUtils.mv 'public/front_end_builds/index.html', 'app/views/front_end_builds/admin/index.html.erb' end end 
+2
source share

All Articles