Skip to content

Commit

Permalink
Update default extensions and move to installer (#1181)
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravtiwari authored Jan 21, 2018
1 parent bf98ffc commit d21f15c
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 14 deletions.
3 changes: 3 additions & 0 deletions lib/install/coffee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 0 additions & 6 deletions lib/install/config/webpacker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ default: &default
cache_manifest: false

extensions:
- .coffee
- .erb
- .js
- .jsx

This comment has been minimized.

Copy link
@jDeppen

jDeppen Oct 16, 2018

(posterity) Saw this error once I removed - .jsx
Field 'browser' doesn't contain a valid alias configuration

- .tsx
- .ts
- .vue
- .sass
- .scss
- .css
Expand Down
2 changes: 1 addition & 1 deletion lib/install/elm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions lib/install/erb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions lib/install/react.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion lib/install/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
end

say "Installing all JavaScript dependencies"
run "yarn add @rails/webpacker [email protected]"
run "yarn add @rails/webpacker"

say "Installing dev server for live reloading"
run "yarn add --dev webpack-dev-server"
Expand Down
6 changes: 6 additions & 0 deletions lib/install/typescript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions lib/install/vue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 0 additions & 6 deletions test/test_app/config/webpacker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ default: &default
cache_manifest: false

extensions:
- .coffee
- .erb
- .js
- .jsx
- .tsx
- .ts
- .vue
- .sass
- .scss
- .css
Expand Down

0 comments on commit d21f15c

Please sign in to comment.