chore(vite): do not use legacy build in development
This commit is contained in:
parent
eba1973d5f
commit
2979d6ac2c
4 changed files with 53 additions and 23 deletions
|
@ -181,4 +181,12 @@ module ApplicationHelper
|
|||
def show_outdated_browser_banner?
|
||||
!supported_browser? && !has_dismissed_outdated_browser_banner?
|
||||
end
|
||||
|
||||
def vite_legacy?
|
||||
if ENV['VITE_LEGACY'] == 'disabled'
|
||||
false
|
||||
else
|
||||
Rails.env.production? || ENV['VITE_LEGACY'] == 'enabled'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
- if content_for?(:footer)
|
||||
= content_for(:footer)
|
||||
|
||||
- if vite_legacy?
|
||||
= vite_legacy_javascript_tag 'application'
|
||||
|
||||
= yield :charts_js
|
||||
|
|
|
@ -133,3 +133,7 @@ SENDINBLUE_BALANCING_VALUE="50"
|
|||
DOLIST_BALANCING_VALUE="50"
|
||||
# Used only by a migration to choose your default regarding procedure archive dossiers after duree_conservation_dossiers_dans_ds
|
||||
# DEFAULT_PROCEDURE_EXPIRES_WHEN_TERMINE_ENABLED=true
|
||||
|
||||
# Enable vite legacy build (IE11). Legacy build is used in production (except if set to "disabled").
|
||||
# You might want to enable it in other environements for testing. Build time will be greatly impacted.
|
||||
VITE_LEGACY=""
|
||||
|
|
|
@ -4,27 +4,17 @@ import ViteLegacy from '@vitejs/plugin-legacy';
|
|||
import FullReload from 'vite-plugin-full-reload';
|
||||
import RubyPlugin from 'vite-plugin-ruby';
|
||||
|
||||
export default defineConfig({
|
||||
resolve: { alias: { '@utils': '/shared/utils.ts' } },
|
||||
build: {
|
||||
sourcemap: true,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
if (id.match('maplibre') || id.match('mapbox')) {
|
||||
return 'maplibre';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
const plugins = [
|
||||
RubyPlugin(),
|
||||
ViteReact({
|
||||
parserPlugins: ['classProperties', 'classPrivateProperties'],
|
||||
jsxRuntime: 'classic'
|
||||
}),
|
||||
FullReload(['config/routes.rb', 'app/views/**/*'], { delay: 200 }),
|
||||
FullReload(['config/routes.rb', 'app/views/**/*'], { delay: 200 })
|
||||
];
|
||||
|
||||
if (shouldBuildLegacy()) {
|
||||
plugins.push(
|
||||
ViteLegacy({
|
||||
targets: [
|
||||
'defaults',
|
||||
|
@ -48,5 +38,32 @@ export default defineConfig({
|
|||
'yet-another-abortcontroller-polyfill'
|
||||
]
|
||||
})
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
resolve: { alias: { '@utils': '/shared/utils.ts' } },
|
||||
build: {
|
||||
sourcemap: true,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
if (id.match('maplibre') || id.match('mapbox')) {
|
||||
return 'maplibre';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins
|
||||
});
|
||||
|
||||
function shouldBuildLegacy() {
|
||||
if (process.env.VITE_LEGACY == 'disabled') {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
process.env.RAILS_ENV == 'production' ||
|
||||
process.env.VITE_LEGACY == 'enabled'
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue