diff --git a/front/vite.config.js b/front/vite.config.js index 6f2820102..facee225d 100644 --- a/front/vite.config.js +++ b/front/vite.config.js @@ -9,54 +9,53 @@ import { visualizer } from 'rollup-plugin-visualizer' // https://vitejs.dev/config/ export default defineConfig(async ({ mode }) => { - const env = loadEnv(mode, fileURLToPath(import.meta.resolve('..')), [ + const envPrefix = [ 'SNOWPACK_', 'SENTRY_', - ]) + ] + + const env = loadEnv(mode, fileURLToPath(import.meta.resolve('..')), envPrefix) const { SNOWPACK_MATOMO_URL, SNOWPACK_MATOMO_SITE_ID } = env const isDevelopment = Boolean(mode === 'development' || env.SENTRY_ENVIRONMENT === 'dev') return { base: env.DEPLOY_PRIME_URL ?? '/', - envPrefix: 'SNOWPACK_', + envPrefix, build: { outDir: 'build', sourcemap: true, rollupOptions: { output: { - manualChunks (id, { getModuleInfo }) { - if (id.match(/\/(@rjsf\/.+|biblatex-csl-converter)\//)) { - return 'metadata' - } - else if (id.match(/\/pagedjs\//)) { - return 'pagedPreview' - } - else if (id.match(/\/(core-js|react|react-.+|redux)\//)) { - return 'react' - } - else if (id.match(/\/(@geist-ui\/core|i18next)\//)) { - return 'ui' - } - else if (id.match(/\/(monaco-editor\/esm\/vs\/editor\/common|yjs|y-.+)/)) { - return 'writerEditorCommon' - } - else if (id.match(/\/monaco-editor\/esm\/vs\/editor/)) { - return 'writerTextEditor' - } - else if (id.match(/\/monaco-editor\/esm\/vs\/(base|common)/)) { - return 'writerBase' - } - // else if (id.match(/\/monaco-editor\/esm\/vs\/base\/browser/)) { - // return 'writerBaseBrowser' - // } - else if (id.match(/\/monaco-editor\/esm\/vs\/(basic-languages|language)\//)) { - return 'writerLanguages' - } - else if (id.match(/\/monaco-editor\/esm\/vs\/platform\//)) { - return 'writerPlatform' - } - - return null + manualChunks: { + metadata: [ + 'biblatex-csl-converter', + '@rjsf/core', + '@rjsf/validator-ajv8' + ], + pagedPreview: ['pagedjs'], + react: [ + 'core-js', + 'i18next', + 'react', + 'react-dom', + 'react-dnd', + 'react-helmet', + 'react-i18next', + 'react-redux', + 'react-router-dom', + 'redux' + ], + ui: [ + '@geist-ui/core', + 'react-feather', + ], + textEditor: [ + 'monaco-editor', + '@monaco-editor/react', + 'y-monaco', + 'y-websocket', + 'yjs' + ] }, }, },