Live Reload
LiveReload with Webpack for views and viewcomponents..
Used 80 times
R
Roland Studer
Usage
Start your webpack-dev-server with
./bin/webpack-dev-server
All changes in `app/views` and `app/components` will trigger a page reload.
Run this command in your Rails app directory in the terminal:
rails app:template LOCATION="https://railsbytes.com/script/V1bs61"
Template Source
Review the code before running this template on your machine.
file = 'config/webpack/development.js'
inject_into_file file, before: "process.env.NODE_ENV = process.env.NODE_ENV || 'development'\n" do <<~EOF
var path = require('path')
EOF
end
inject_into_file file, after: "const environment = require('./environment')\n" do <<~EOF
environment.config.devServer.watchContentBase = true
environment.config.devServer.contentBase = [
path.join(__dirname, '../../app/views'),
path.join(__dirname, '../../app/components')
]
EOF
end