Skip to content

Commit 2893b7d

Browse files
committed
build: use Vite instead of Craco / CRA as a build system
1 parent e6cc649 commit 2893b7d

File tree

11 files changed

+1343
-10153
lines changed

11 files changed

+1343
-10153
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# production
1212
/build
13+
/dist
1314

1415
# misc
1516
.DS_Store

craco.config.js

-5
This file was deleted.

index.html

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="de">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="/favicon.ico" />
6+
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
<meta name="theme-color" content="#000000" />
9+
<meta name="description" content="Hering / Sardine / Sardina" />
10+
11+
<link rel="manifest" href="/manifest.json" />
12+
13+
<title></title>
14+
</head>
15+
<body>
16+
<noscript>You need to enable JavaScript to run this app.</noscript>
17+
<div id="root"></div>
18+
19+
<script type="module" src="/src/index.tsx"></script>
20+
</body>
21+
</html>

package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
"version": "0.1.0",
55
"private": true,
66
"scripts": {
7-
"start": "BROWSER=none PORT=3001 craco start",
8-
"build": "craco build",
9-
"test": "craco test",
10-
"eject": "craco eject"
7+
"start": "vite dev",
8+
"build": "vite build",
9+
"preview": "vite preview"
1110
},
1211
"eslintConfig": {
1312
"extends": [
1413
"react-app"
1514
]
1615
},
16+
"type": "module",
1717
"browserslist": {
1818
"production": [
1919
">0.2%",
@@ -44,14 +44,14 @@
4444
"remark-gfm": "^4.0.0"
4545
},
4646
"devDependencies": {
47-
"@craco/craco": "^7.1.0",
4847
"@types/node": "^20.11.16",
4948
"@types/react": "^18.2.54",
5049
"@types/react-dom": "^18.2.18",
5150
"@types/react-router-dom": "^5.3.3",
52-
"craco-less": "^3.0.1",
53-
"react-scripts": "^5.0.1",
51+
"@vitejs/plugin-react": "^4.2.1",
52+
"less": "^4.2.0",
5453
"typescript": "~5.1.0",
55-
"webpack": "^5.0.0"
54+
"vite": "^5.2.11",
55+
"vite-tsconfig-paths": "^4.3.2"
5656
}
5757
}

public/index.html

-29
This file was deleted.

src/pages/calendar/components/IcsDownload.tsx

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import React, {useEffect, useState} from 'react'
2-
import {TaskT} from './Task'
3-
import {ChapterT} from '../../section/components/Chapter'
4-
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'
5-
import {useTranslation} from "react-i18next"
6-
import {faCalendarDays} from "@fortawesome/free-solid-svg-icons";
1+
import React, { useEffect, useState } from 'react'
2+
import { TaskT } from './Task'
3+
import { ChapterT } from '../../section/components/Chapter'
4+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
5+
import { useTranslation } from "react-i18next"
6+
import { faCalendarDays } from "@fortawesome/free-solid-svg-icons";
7+
import ics, { EventAttributes } from "ics";
78

89
type Props = {
910
tasks: TaskT[]
@@ -23,16 +24,14 @@ function buildLinks(task: TaskT): string {
2324
}
2425

2526
async function generateIcsLink(tasks: TaskT[], calendarTitlePrefix: string): Promise<string> {
26-
const ics = require('ics')
27-
2827
const events = tasks.map(function (task) {
2928
const deadline = task.deadline
3029
const alarms = []
3130

3231
alarms.push({
3332
action: 'display',
3433
description: buildDescription(task),
35-
trigger: {hours: 1, before: true},
34+
trigger: { hours: 1, before: true },
3635
})
3736

3837
return {
@@ -44,7 +43,7 @@ async function generateIcsLink(tasks: TaskT[], calendarTitlePrefix: string): Pro
4443
status: 'CONFIRMED',
4544
busyStatus: 'FREE',
4645
alarms: alarms
47-
}
46+
} as EventAttributes
4847
})
4948

5049
return new Promise((resolve, reject) => {
@@ -59,7 +58,7 @@ async function generateIcsLink(tasks: TaskT[], calendarTitlePrefix: string): Pro
5958
return
6059
}
6160

62-
const data = new Blob([value], {type: 'text/calendar'});
61+
const data = new Blob([value], { type: 'text/calendar' });
6362
const link = window.URL.createObjectURL(data);
6463
resolve(link)
6564
})
@@ -68,7 +67,7 @@ async function generateIcsLink(tasks: TaskT[], calendarTitlePrefix: string): Pro
6867

6968
function IcsDownload(props: Props) {
7069

71-
const {t} = useTranslation();
70+
const { t } = useTranslation();
7271
const [downloadLink, setDownloadLink] = useState<string>();
7372

7473
useEffect(() => {
@@ -96,7 +95,7 @@ function IcsDownload(props: Props) {
9695

9796
return (
9897
<a className="download-btn" id="ics-download"
99-
download={t('calendarPage.ics.filename', {calendarTitlePrefix: spacedCalendarPrefix})}
98+
download={t('calendarPage.ics.filename', { calendarTitlePrefix: spacedCalendarPrefix })}
10099
href={downloadLink}>
101100
<FontAwesomeIcon icon={faCalendarDays}/>
102101
{t('calendarPage.ics.download')}

src/pages/search/components/SearchForm.tsx

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import React, {useCallback, useEffect, useRef, useState} from 'react'
2-
import {useTranslation} from "react-i18next"
1+
import React, { useCallback, useEffect, useRef, useState } from 'react'
2+
import { useTranslation } from "react-i18next"
33
import Loading from '../../../components/loading/Loading'
4-
import {ChapterT} from '../../section/components/Chapter';
4+
import { ChapterT } from '../../section/components/Chapter';
55
import Markdown from 'react-markdown';
66
import remarkGfm from 'remark-gfm';
7-
import {LinkComponent} from '../../../helper/MarkdownComponents';
7+
import { LinkComponent } from '../../../helper/MarkdownComponents';
88
import SearchInput from './SearchInput';
9-
import {Link, useSearchParams} from "react-router-dom";
10-
import {SearchHelper} from "../../../helper/SearchHelper";
11-
import {SectionT} from "../../section/SectionPage";
9+
import { Link, useSearchParams } from "react-router-dom";
10+
import { SearchHelper } from "../../../helper/SearchHelper";
11+
import { SectionT } from "../../section/SectionPage";
1212

1313
type Props = {
1414
sections: SectionT[]
@@ -23,15 +23,15 @@ type SearchResult = {
2323

2424
function SearchForm(props: Props) {
2525

26-
const {t} = useTranslation()
26+
const { t } = useTranslation()
2727
const [searchParams, setSearchParams] = useSearchParams();
2828

2929
const isQueryLoaded = useRef<boolean>(false);
3030
const [keyword, setKeyword] = useState<string>('')
3131
const [searchResults, setSearchResults] = useState<SearchResult[]>([])
3232
const [isLoadingResults, setIsLoadingResults] = useState<boolean>(false)
3333

34-
const timeoutId = useRef<NodeJS.Timeout | undefined>();
34+
const timeoutId = useRef<number | undefined>();
3535
const searchableSectionChapters = useRef<ChapterT[]>(props.sections
3636
.reduce((chapters: ChapterT[], currentSection: SectionT) => chapters.concat(currentSection.chapters), []))
3737

@@ -97,9 +97,9 @@ function SearchForm(props: Props) {
9797

9898
setKeyword(keyword)
9999
const queryParams = keyword.length > 0
100-
? {'keyword': keyword}
100+
? { 'keyword': keyword }
101101
: undefined;
102-
setSearchParams(queryParams, {replace: true})
102+
setSearchParams(queryParams, { replace: true })
103103

104104
executeSearch(keyword)
105105
}
@@ -129,7 +129,7 @@ function SearchForm(props: Props) {
129129

130130
return <div>{t('searchPage.noResults')}</div>
131131
}
132-
return <div> {t('searchPage.noKeyword', {amountOfCharacters: 3})}</div>
132+
return <div> {t('searchPage.noKeyword', { amountOfCharacters: 3 })}</div>
133133
}
134134
return null
135135
}

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"compilerOptions": {
3-
"target": "es6",
3+
"target": "ESNext",
44
"lib": [
55
"dom",
66
"dom.iterable",
77
"esnext"
88
],
9+
"types": ["vite/client"],
910
"allowJs": true,
1011
"skipLibCheck": true,
1112
"esModuleInterop": true,

vite-env.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

vite.config.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { defineConfig } from 'vite'
2+
import react from '@vitejs/plugin-react'
3+
import viteTsconfigPaths from 'vite-tsconfig-paths'
4+
5+
export default defineConfig({
6+
base: '',
7+
plugins: [react(), viteTsconfigPaths()],
8+
server: {
9+
open: false,
10+
port: 3001,
11+
},
12+
css: {
13+
preprocessorOptions: {
14+
less: {},
15+
},
16+
}
17+
})

0 commit comments

Comments
 (0)