Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update default extensions and move to installer #1181

Merged
merged 2 commits into from
Jan 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inserting YAML like this at the corrected indentation level seems a little brittle. Do we do it this way elsewhere in Rails?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find any reference but this is how it's done in Rails: https://github.com/rails/rails/blob/63f0c04850dd0bcdc7d35266e81fa1a7778570a8/railties/lib/rails/generators/actions.rb#L326

May be we can borrow that method.


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
- .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 @@ -35,7 +35,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