Skip to content

Commit

Permalink
Revert "fix(import): present in vite-legacy"
Browse files Browse the repository at this point in the history
This reverts commit 65f3f64.
  • Loading branch information
Martin committed Jun 30, 2022
1 parent c6a3d6a commit 6661039
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ gem 'strong_migrations' # lint database migrations
gem 'turbo-rails'
gem 'typhoeus'
gem 'view_component'
gem 'vite_plugin_legacy'
gem 'vite_rails'
gem 'warden'
gem 'zipline'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,8 @@ GEM
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
vite_plugin_legacy (3.0.2)
vite_ruby (~> 3.0, >= 3.0.4)
vite_rails (3.0.9)
railties (>= 5.1, < 8)
vite_ruby (~> 3.0)
Expand Down Expand Up @@ -910,6 +912,7 @@ DEPENDENCIES
typhoeus
vcr
view_component
vite_plugin_legacy
vite_rails
warden
web-console
Expand Down
42 changes: 41 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from 'vite';
import ViteReact from '@vitejs/plugin-react';
import ViteLegacy from '@vitejs/plugin-legacy';
import FullReload from 'vite-plugin-full-reload';
import RubyPlugin from 'vite-plugin-ruby';

Expand All @@ -12,10 +13,49 @@ const plugins = [
FullReload(['config/routes.rb', 'app/views/**/*'], { delay: 200 })
];

if (shouldBuildLegacy()) {
plugins.push(
ViteLegacy({
targets: [
'defaults',
'Chrome >= 50',
'Edge >= 14',
'Firefox >= 50',
'Opera >= 40',
'Safari >= 8',
'iOS >= 8',
'IE >= 11'
],
additionalLegacyPolyfills: [
'@stimulus/polyfills',
'@webcomponents/custom-elements',
'@webcomponents/template',
'event-target-polyfill',
'formdata-polyfill',
'intersection-observer',
'regenerator-runtime/runtime',
'whatwg-fetch',
'yet-another-abortcontroller-polyfill'
]
})
);
}

export default defineConfig({
resolve: { alias: { '@utils': '/shared/utils.ts' } },
build: {
sourcemap: true
sourcemap: true,
polyfillDynamicImport: true
},
plugins
});

function shouldBuildLegacy() {
if (process.env.VITE_LEGACY == 'disabled') {
return false;
}
return (
process.env.RAILS_ENV == 'production' ||
process.env.VITE_LEGACY == 'enabled'
);
}

0 comments on commit 6661039

Please sign in to comment.