• Stars
    star
    121
  • Rank 283,310 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 3 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

♻️ Automatically reload the page when files are modified

vite-plugin-full-reload

Automatically reload the page when files are modified


Why? 🤔

When using Vite Ruby, I wanted to see changes to server-rendered layouts and templates without having to manually reload the page.

Also, in JS From Routes path helpers are generated when Rails reload is triggered.

Triggering a page reload when config/routes.rb is modified makes the DX very smooth.

Installation 💿

Install the package as a development dependency:

npm i -D vite-plugin-full-reload # yarn add -D vite-plugin-full-reload

Usage 🚀

Add it to your plugins in vite.config.ts

import { defineConfig } from 'vite'
import FullReload from 'vite-plugin-full-reload'

export default defineConfig({
  plugins: [
    FullReload(['config/routes.rb', 'app/views/**/*'])
  ],
})

This is useful to trigger a page refresh for files that are not being imported, such as server-rendered templates.

To see which file globbing options are available, check picomatch.

Configuration ⚙️

The following options can be provided:

  • root

    Files will be resolved against this directory.

    Default: process.cwd()

    FullReload('config/routes.rb', { root: __dirname }),
  • delay

    How many milliseconds to wait before reloading the page after a file change. It can be used to offset slow template compilation in Rails.

    Default: 0

    FullReload('app/views/**/*', { delay: 100 })
  • always

    Whether to refresh the page even if the modified HTML file is not currently being displayed.

    Default: true

    FullReload('app/views/**/*', { always: false })

Acknowledgements

  • vite-plugin-live-reload

    This is a nice plugin, I found it right before publishing this one.

    I've made two PRs that were needed to support these use cases.

    At this point in time they are very similar, except this library doesn't create another chokidar watcher.

License

This library is available as open source under the terms of the MIT License.

More Repositories

1

vite_ruby

⚡️ Vite.js in Ruby, bringing joy to your JavaScript experience
Ruby
1,124
star
2

iles

🏝 The joyful site generator
TypeScript
1,043
star
3

vite-plugin-image-presets

🖼 Image Presets for Vite.js apps
TypeScript
243
star
4

vite-plugin-environment

Easily expose environment variables in Vite.js
TypeScript
132
star
5

oj_serializers

⚡️ Faster JSON serialization for Ruby on Rails. Easily migrate away from Active Model Serializers.
Ruby
98
star
6

js_from_routes

🛣️ Generate path helpers and API methods from your Rails routes
Ruby
86
star
7

request_store_rails

📦 Per-request global storage for Rails prepared for multi-threaded apps
Ruby
83
star
8

types_from_serializers

✅ Generate TypeScript interfaces from your JSON serializers
Ruby
71
star
9

vuex-stores

🗄 Store objects for Vuex, a simple and more fluid API for state-management.
JavaScript
63
star
10

vue-custom-element-example

An example on how to define custom elements using Vue 3
TypeScript
54
star
11

mongoid_includes

🌿 Improves eager loading support for Mongoid
Ruby
46
star
12

jekyll-vite

⚡️🩸 Use Vite.js in Jekyll as your assets pipeline
Ruby
44
star
13

queryable

❔ Gives your queries a home and avoid tucking scopes inside your models
Ruby
42
star
14

vite-plugin-stimulus-hmr

⚡️ HMR for Stimulus controllers in Vite.js
TypeScript
42
star
15

stimulus-vite-helpers

Helpers to easily load all your Stimulus controllers when using Vite.js
TypeScript
37
star
16

capybara-compose

✅ Easily write fluent integration tests with Capybara in Ruby
Ruby
31
star
17

better_settings

⚙ Settings for Ruby apps – fast, immutable, better.
Ruby
20
star
18

vite-plugin-bugsnag

Report builds and upload source maps to Bugsnag
TypeScript
18
star
19

i18n_multitenant

🌎 Provides a convenient way to use tenant-specific translations
Ruby
16
star
20

vite-plugin-manifest-sri

Subresource Integrity for Vite.js manifest files
JavaScript
13
star
21

resourcerer

✨ Works like magic to dry up your controllers
Ruby
10
star
22

sublime-toggle-dark-mode

🌚🌞 Toggle between dark and light mode in Sublime Text 4
JavaScript
9
star
23

pakiderm

🐘 Pakiderm will never forget the return value
Ruby
7
star
24

presenter_rails

🔭 Expose your view models in a convenient way
Ruby
6
star
25

vite-plugin-erb

Use ERB files in Vite.js projects with a Ruby backend
TypeScript
5
star
26

journeyman

Let your factories use your business logic, making them flexible and easier to update.
Ruby
5
star
27

jekyll-vite-minima

⚡️🩸 Use Vite.js in Jekyll minima theme as your assets pipeline
Ruby
3
star
28

automatic-music-transcription

Automatically exported from code.google.com
C
2
star
29

vite-plugin-xdm

Use XDM in VIte.js
JavaScript
2
star
30

crouton

🍞 Context sensitive notifications for Rails
Ruby
1
star
31

fast-food-mvc

Automatically exported from code.google.com
C#
1
star
32

ElMassimo

1
star
33

vite-vue-router-hmr-repro

Vue
1
star