Skip to content
On this page

Plugin Legacy

When using @vitejs/plugin-legacy, it's necessary to use additional tag helpers to output nomodule script tags and polyfills.

Installation ๐Ÿ’ฟ

Add this line to your application's Gemfile:

gem 'vite_plugin_legacy'

And then run:

bundle install

Tag Helpers ๐Ÿท

In order to include the polyfills and script tags you can using the following helpers:

The polyfill is included by default when using vite_legacy_javascript_tag

  <%= csrf_meta_tags %>
  <%= csp_meta_tag %>
  <%= vite_client_tag %>

  <%= vite_javascript_tag 'application' %>
  <%= yield %>
  <%= vite_legacy_javascript_tag 'application' %>

Notice that it's necessary to still use vite_javascript_tag in order to render module tags for modern browsers.

Plugin Legacy has loaded