From a3c4480cb345eb3e6554e3be2a6fa1cb01e1bfd1 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 14 Jan 2018 15:10:51 +0000 Subject: [PATCH 1/2] Update default extensions and move to installer --- lib/install/coffee.rb | 3 +++ lib/install/config/webpacker.yml | 6 ------ lib/install/elm.rb | 2 +- lib/install/erb.rb | 3 +++ lib/install/react.rb | 3 +++ lib/install/template.rb | 2 +- lib/install/typescript.rb | 6 ++++++ lib/install/vue.rb | 3 +++ 8 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/install/coffee.rb b/lib/install/coffee.rb index b174a2dcf..37e88acbc 100644 --- a/lib/install/coffee.rb +++ b/lib/install/coffee.rb @@ -12,6 +12,9 @@ "environment.loaders.append('coffee', coffee)\n", before: "module.exports" +say "Updating webpack paths to include .coffee file extension" +insert_into_file Webpacker.config.config_path, " - .coffee\n", after: /extensions:\n/ + say "Copying the example entry file to #{Webpacker.config.source_entry_path}" copy_file "#{__dir__}/examples/coffee/hello_coffee.coffee", "#{Webpacker.config.source_entry_path}/hello_coffee.coffee" diff --git a/lib/install/config/webpacker.yml b/lib/install/config/webpacker.yml index 4183fea48..d3f24e1b4 100644 --- a/lib/install/config/webpacker.yml +++ b/lib/install/config/webpacker.yml @@ -14,13 +14,7 @@ default: &default cache_manifest: false extensions: - - .coffee - - .erb - .js - - .jsx - - .tsx - - .ts - - .vue - .sass - .scss - .css diff --git a/lib/install/elm.rb b/lib/install/elm.rb index 3a808c1c2..2cbfebc02 100644 --- a/lib/install/elm.rb +++ b/lib/install/elm.rb @@ -25,7 +25,7 @@ run "yarn add --dev elm-hot-loader" run "yarn run elm package install -- --yes" -say "Updating webpack paths to include Elm file extension" +say "Updating webpack paths to include .elm file extension" insert_into_file Webpacker.config.config_path, " - .elm\n", after: /extensions:\n/ say "Updating Elm source location" diff --git a/lib/install/erb.rb b/lib/install/erb.rb index 62912371c..d4fe34570 100644 --- a/lib/install/erb.rb +++ b/lib/install/erb.rb @@ -12,6 +12,9 @@ "environment.loaders.append('erb', erb)\n", before: "module.exports" +say "Updating webpack paths to include .erb file extension" +insert_into_file Webpacker.config.config_path, " - .erb\n", after: /extensions:\n/ + say "Copying the example entry file to #{Webpacker.config.source_entry_path}" copy_file "#{__dir__}/examples/erb/hello_erb.js.erb", "#{Webpacker.config.source_entry_path}/hello_erb.js.erb" diff --git a/lib/install/react.rb b/lib/install/react.rb index 0c967d403..d804b6c8f 100644 --- a/lib/install/react.rb +++ b/lib/install/react.rb @@ -22,6 +22,9 @@ say "Copying react example entry file to #{Webpacker.config.source_entry_path}" copy_file "#{__dir__}/examples/react/hello_react.jsx", "#{Webpacker.config.source_entry_path}/hello_react.jsx" +say "Updating webpack paths to include .jsx file extension" +insert_into_file Webpacker.config.config_path, " - .jsx\n", after: /extensions:\n/ + say "Installing all react dependencies" run "yarn add react react-dom babel-preset-react prop-types" diff --git a/lib/install/template.rb b/lib/install/template.rb index 19d3ac4f0..c067d97a9 100644 --- a/lib/install/template.rb +++ b/lib/install/template.rb @@ -35,7 +35,7 @@ end say "Installing all JavaScript dependencies" -run "yarn add @rails/webpacker coffeescript@1.12.7" +run "yarn add @rails/webpacker" say "Installing dev server for live reloading" run "yarn add --dev webpack-dev-server" diff --git a/lib/install/typescript.rb b/lib/install/typescript.rb index 0643dfb2c..c904120b3 100644 --- a/lib/install/typescript.rb +++ b/lib/install/typescript.rb @@ -30,6 +30,12 @@ say "Copying tsconfig.json to the Rails root directory for typescript" copy_file "#{__dir__}/examples/#{example_source}/tsconfig.json", "tsconfig.json" +say "Updating webpack paths to include .ts file extension" +insert_into_file Webpacker.config.config_path, " - .ts\n", after: /extensions:\n/ + +say "Updating webpack paths to include .tsx file extension" +insert_into_file Webpacker.config.config_path, " - .tsx\n", after: /extensions:\n/ + say "Copying the example entry file to #{Webpacker.config.source_entry_path}" copy_file "#{__dir__}/examples/typescript/hello_typescript.ts", "#{Webpacker.config.source_entry_path}/hello_typescript.ts" diff --git a/lib/install/vue.rb b/lib/install/vue.rb index 2bef2324e..2687e883d 100644 --- a/lib/install/vue.rb +++ b/lib/install/vue.rb @@ -12,6 +12,9 @@ "environment.loaders.append('vue', vue)\n", before: "module.exports" +say "Updating webpack paths to include .vue file extension" +insert_into_file Webpacker.config.config_path, " - .vue\n", after: /extensions:\n/ + say "Copying the example entry file to #{Webpacker.config.source_entry_path}" copy_file "#{__dir__}/examples/vue/hello_vue.js", "#{Webpacker.config.source_entry_path}/hello_vue.js" From 4671458635ea07c3d5285a8d38352e1ca23950a4 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 14 Jan 2018 15:21:13 +0000 Subject: [PATCH 2/2] Update test app config --- test/test_app/config/webpacker.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/test_app/config/webpacker.yml b/test/test_app/config/webpacker.yml index fb7cba0bd..c2a2a46c6 100644 --- a/test/test_app/config/webpacker.yml +++ b/test/test_app/config/webpacker.yml @@ -16,13 +16,7 @@ default: &default cache_manifest: false extensions: - - .coffee - - .erb - .js - - .jsx - - .tsx - - .ts - - .vue - .sass - .scss - .css