Skip to content

Commit

Permalink
Dynamic imports for most routes, for better chunk size
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Feb 14, 2024
1 parent f88d9d0 commit 60eddba
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ As this project is a user-facing application, the places in the semantic version
### Added

- Basic functionality for adding and removing metadata resources [#145](https://github.com/spraakbanken/mink-frontend/issues/145)
- Some dynamic imports to reduce main chunk size

### Changed

Expand Down
17 changes: 9 additions & 8 deletions src/router/corpus.routes.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { type RouteRecordRaw } from "vue-router";
import CreateCorpus from "@/corpus/CreateCorpus.vue";
import CorpusView from "@/corpus/CorpusView.vue";
import CorpusOverview from "@/corpus/CorpusOverview.vue";
import CorpusMetadata from "@/corpus/config/CorpusMetadata.vue";
import CorpusConfiguration from "@/corpus/config/CorpusConfiguration.vue";
import CorpusResult from "@/corpus/exports/CorpusResult.vue";
import CorpusDelete from "@/corpus/CorpusDelete.vue";
import SourceView from "@/corpus/sources/SourceView.vue";
const CreateCorpus = () => import("@/corpus/CreateCorpus.vue");
const CorpusView = () => import("@/corpus/CorpusView.vue");
const CorpusOverview = () => import("@/corpus/CorpusOverview.vue");
const CorpusMetadata = () => import("@/corpus/config/CorpusMetadata.vue");
const CorpusConfiguration = () =>
import("@/corpus/config/CorpusConfiguration.vue");
const CorpusResult = () => import("@/corpus/exports/CorpusResult.vue");
const CorpusDelete = () => import("@/corpus/CorpusDelete.vue");
const SourceView = () => import("@/corpus/sources/SourceView.vue");

const corpusRoutes: RouteRecordRaw[] = [
{ path: "/corpus", redirect: "/library" },
Expand Down
4 changes: 2 additions & 2 deletions src/router/main.routes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { type RouteRecordRaw } from "vue-router";
import HomeView from "@/home/HomeView.vue";
import LibraryView from "@/library/LibraryView.vue";
const LibraryView = () => import("@/library/LibraryView.vue");
import LoginView from "@/auth/LoginView.vue";
import SignupView from "@/auth/SignupView.vue";
import UserView from "@/user/UserView.vue";
const UserView = () => import("@/user/UserView.vue");
import AccessDenied from "@/auth/AccessDenied.vue";
import NotFound from "@/page/NotFound.vue";
import corpusRoutes from "./corpus.routes";
Expand Down
8 changes: 4 additions & 4 deletions src/router/metadata.routes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type RouteRecordRaw } from "vue-router";
import MetadataView from "@/metadata/MetadataView.vue";
import MetadataOverview from "@/metadata/MetadataOverview.vue";
import CreateMetadata from "@/metadata/CreateMetadata.vue";
import MetadataDelete from "@/metadata/MetadataDelete.vue";
const MetadataView = () => import("@/metadata/MetadataView.vue");
const MetadataOverview = () => import("@/metadata/MetadataOverview.vue");
const CreateMetadata = () => import("@/metadata/CreateMetadata.vue");
const MetadataDelete = () => import("@/metadata/MetadataDelete.vue");

const metadataRoutes: RouteRecordRaw[] = [
{
Expand Down
7 changes: 7 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,12 @@ export default defineConfig(async ({ mode }) => {
test: {
environment: "happy-dom",
},
build: {
rollupOptions: {
output: {
experimentalMinChunkSize: 5000,
},
},
},
};
});

0 comments on commit 60eddba

Please sign in to comment.