Skip to content

Commit

Permalink
end webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
damienlethiec committed Feb 9, 2018
1 parent 0bc48fb commit 724c416
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 8 deletions.
27 changes: 27 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"extends": ["eslint-config-airbnb-base", "prettier"],

"plugins": ["prettier"],

"env": {
"browser": true
},

"rules": {
"prettier/prettier": "error"
},

"parser": "babel-eslint",

"settings": {
"import/resolver": {
"webpack": {
"config": {
"resolve": {
"modules": ["frontend", "node_modules"]
}
}
}
}
}
}
3 changes: 3 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "stylelint-config-standard"
}
8 changes: 5 additions & 3 deletions app/template.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
copy_file 'app/controllers/application_controller.rb', force: true
copy_file 'app/controllers/pages_controller.rb'
copy_file 'app/views/pages/home.html.haml'
copy_file 'app/controllers/application_controller.rb', force: true
copy_file 'app/controllers/pages_controller.rb'
copy_file 'app/views/layouts/application.html.erb', force: true
copy_file 'app/views/pages/home.html.erb'


16 changes: 16 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title><%= Rails.application.class.parent_name %></title>
<%= csrf_meta_tags %>
<%= action_cable_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all' %>
</head>
<body>
<%= yield %>
<%= javascript_include_tag 'application' %>
<%= javascript_pack_tag 'application' %>
</body>
</html>
1 change: 1 addition & 0 deletions app/views/pages/home.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Hello from <%= Rails.application.class.parent_name %></h1>
1 change: 0 additions & 1 deletion app/views/pages/home.html.haml

This file was deleted.

22 changes: 18 additions & 4 deletions template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ def apply_template!

after_bundle do
setup_gems
install_optional_gems
setup_optional_gems

setup_front_end
optional_options_front_end
setup_npm_packages

install_optional_gems
setup_optional_gems

run 'bundle binstubs bundler --force'

run 'rails db:create db:migrate'

Expand Down Expand Up @@ -135,13 +139,23 @@ def remove_uneeded_stuff

def add_fancy_setup
FileUtils.mv 'app/javascript', 'frontend'
gsub_file 'app/views/layouts/application.html.haml', 'javascript_include_tag', 'javascript_pack_tag'
gsub_file 'app/views/layouts/application.html.haml', 'stylesheet_link_tag', 'stylesheet_pack_tag'
create_file "frontend/packs/application.css"
insert_into_file 'frontend/packs/application.js', "import './application.css';\n", after: /application.html.erb\n/
gsub_file 'app/views/layouts/application.html.erb', "<%= javascript_include_tag 'application' %>\n", ''
gsub_file 'app/views/layouts/application.html.erb', 'stylesheet_link_tag', 'stylesheet_pack_tag'
gsub_file 'config/webpacker.yml', 'app/javascript', 'frontend'
insert_into_file 'app/controllers/application_controller.rb', " prepend_view_path Rails.root.join('frontend')\n", after: /exception\n/
append_to_file 'Procfile', "assets: bin/webpack-dev-server\n"
end

def setup_npm_packages
run 'yarn add eslint babel-eslint eslint-config-airbnb-base eslint-config-prettier eslint-import-resolver-webpack eslint-plugin-import eslint-plugin-prettier lint-staged pre-commit prettier stylelint stylelint-config-standard--dev'
copy_file '.eslintrc'
copy_file '.stylelintrc'
run 'yarn add normalize.css'
run 'yarn install'
end

def setup_git
git flow: 'init -d'
git add: '.'
Expand Down

0 comments on commit 724c416

Please sign in to comment.