Skip to content

Instantly share code, notes, and snippets.

@justin808
Created September 16, 2014 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justin808/98c9ace3a9af5a17b0b6 to your computer and use it in GitHub Desktop.
Save justin808/98c9ace3a9af5a17b0b6 to your computer and use it in GitHub Desktop.
Create rails-bundle.js file by using webpack. More details here: https://github.com/justin808/react-webpack-rails-tutorial.
# lib/tasks/assets.rake
# The webpack task must run before assets:environment task.
# Otherwise Sprockets cannot find the files that webpack produces.
Rake::Task['assets:precompile']
.clear_prerequisites
.enhance(['assets:compile_environment'])
namespace :assets do
# In this task, set prerequisites for the assets:precompile task
task :compile_environment => :webpack do
Rake::Task['assets:environment'].invoke
end
desc 'Compile assets with webpack'
task :webpack do
sh 'cd webpack && $(npm bin)/webpack --config webpack.rails.config.js'
end
task :clobber do
rm_rf "#{RailsReactTutorial::Application.config.root}/app/assets/javascripts/rails-bundle.js"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment