aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2016-12-09 12:19:43 -0800
committerGitHub <noreply@github.com>2016-12-09 12:19:43 -0800
commit8c947eb6e95f50ae88e19c0f036bd4a3d3b2dece (patch)
treeefe333e56326dc8984e38c24d48771ead142e585 /railties
parent1399d5c1e0b3a9f7f979523075731f9c67c4e258 (diff)
downloadrails-8c947eb6e95f50ae88e19c0f036bd4a3d3b2dece.tar.gz
rails-8c947eb6e95f50ae88e19c0f036bd4a3d3b2dece.tar.bz2
rails-8c947eb6e95f50ae88e19c0f036bd4a3d3b2dece.zip
Basic --webpack delegation to new webpacker gem (#27288)
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/generators/app_base.rb15
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb2
2 files changed, 16 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index aba68d6db2..2f7339e7f5 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -33,6 +33,9 @@ module Rails
class_option :javascript, type: :string, aliases: "-j",
desc: "Preconfigure for selected JavaScript library"
+ class_option :webpack, type: :boolean, default: false,
+ desc: "Preconfigure for app-like JavaScript with Webpack"
+
class_option :skip_yarn, type: :boolean, default: false,
desc: "Don't use Yarn for managing JavaScript dependencies"
@@ -128,6 +131,7 @@ module Rails
database_gemfile_entry,
webserver_gemfile_entry,
assets_gemfile_entry,
+ webpacker_gemfile_entry,
javascript_gemfile_entry,
jbuilder_gemfile_entry,
psych_gemfile_entry,
@@ -315,6 +319,13 @@ module Rails
gems
end
+ def webpacker_gemfile_entry
+ if options[:webpack]
+ comment = "Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker"
+ GemfileEntry.new "webpacker", "~> 0.1", comment
+ end
+ end
+
def jbuilder_gemfile_entry
comment = "Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder"
GemfileEntry.new "jbuilder", "~> 2.5", comment, {}, options[:api]
@@ -414,6 +425,10 @@ module Rails
bundle_command("install") if bundle_install?
end
+ def run_webpack
+ rails_command "webpacker:install"
+ end
+
def generate_spring_binstubs
if bundle_install? && spring_install?
bundle_command("exec spring binstub --all")
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index a8586d56dd..19d3ba2f0f 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -357,7 +357,7 @@ module Rails
end
public_task :apply_rails_template, :run_bundle
- public_task :generate_spring_binstubs
+ public_task :run_webpack, :generate_spring_binstubs
def run_after_bundle_callbacks
@after_bundle_callbacks.each(&:call)