Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: migrate to Vite for fast and smaller build #159

Draft
wants to merge 36 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
13fe44b
build: migrate to use vite for building fast and modern output
MaikoTan May 31, 2024
27951e6
build: enable minify
MaikoTan May 31, 2024
6cca741
fix: add entry for raidemulator
MaikoTan May 31, 2024
0f78b8a
build: move vite config outside
MaikoTan May 31, 2024
30f9ed6
lint: fix current lint errors
MaikoTan May 31, 2024
0d158aa
build: add production config
MaikoTan May 31, 2024
11b778e
build: add timerbar_test.html into dev config
MaikoTan May 31, 2024
16878ba
build: add manual chunks
MaikoTan May 31, 2024
7473a37
build: add checker plugin in non-CI env
MaikoTan May 31, 2024
d507451
fix: change back vscode config unwilling change
MaikoTan May 31, 2024
a5885f6
build: set target safari to 16
MaikoTan May 31, 2024
bb6e965
build: add copy plugin for static files
MaikoTan May 31, 2024
8ddaef5
build: move manual chunks to base config
MaikoTan May 31, 2024
23c1644
build: add HMR for manifest files
MaikoTan Jun 3, 2024
c48ea23
chore: apply vite's type hints
MaikoTan Jun 3, 2024
877d684
Merge branch 'master' into vite
MaikoTan Jul 21, 2024
64a39d2
chore: add type defs of dedent
MaikoTan Jul 21, 2024
41a43f8
build: fix windows path in building
MaikoTan Jul 21, 2024
839bd59
build: add resources to common
MaikoTan Jul 21, 2024
7ea3dfe
Merge remote-tracking branch 'origin/main' into vite
MaikoTan Dec 5, 2024
3379686
refactor: use *.manifest instead of manifest.txt
MaikoTan Dec 5, 2024
ac52d55
better asset handle
MaikoTan Dec 5, 2024
a85379e
fix timeline not handled by manual chunks
MaikoTan Dec 5, 2024
0302403
update lockfile
MaikoTan Dec 5, 2024
2981e12
Merge branch 'main' into vite
MaikoTan Dec 6, 2024
5f3a2db
update lockfile
MaikoTan Dec 6, 2024
dcb7c80
update tsconfig
MaikoTan Dec 6, 2024
a549996
refactor!: remove webpack stuffs
MaikoTan Dec 6, 2024
4968645
update lockfiles
MaikoTan Dec 6, 2024
e11d07c
fix versions and lockfile
MaikoTan Dec 6, 2024
16cdc61
revert?
MaikoTan Dec 6, 2024
4d72bf9
fix: add vite files to eslint tsconfig
MaikoTan Dec 6, 2024
9c10415
fix: generate coverage report
MaikoTan Dec 6, 2024
5c14c38
fix: generate coverage report
MaikoTan Dec 6, 2024
04ec307
use systemjs for local build
MaikoTan Dec 7, 2024
f37d9f4
try use rollup directly (incomplete)
MaikoTan Dec 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ const rules = {
'error',
{
'caseSensitive': true,
'ignore': [
'.*\\.manifest$',
],
},
],
'import/no-useless-path-segments': 'error',
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"*.jsx": "${capture}.js",
"*.tsx": "${capture}.ts",
"package.json": ".npmrc,package-lock.json, yarn.lock,.editorconfig,.eslintrc.cjs,.markdownlint.yml,.mocharc.cjs",
"tsconfig.json": "tsconfig.*.json,tsconfig-for-webpack.json",
"tsconfig.json": "tsconfig.*.json",
".gitignore": ".gitattributes",
"README.md": "CONTRIBUTING.md,CODE_OF_CONDUCT.md,LICENSE"
},
Expand All @@ -40,7 +40,7 @@
"*.jsx": "${capture}.js",
"*.tsx": "${capture}.ts",
"package.json": ".npmrc,package-lock.json, yarn.lock,.editorconfig,.eslintrc.cjs,.markdownlint.yml,.mocharc.cjs",
"tsconfig.json": "tsconfig.*.json,tsconfig-for-webpack.json",
"tsconfig.json": "tsconfig.*.json",
".gitignore": ".gitattributes",
"README.md": "CONTRIBUTING.md,CODE_OF_CONDUCT.md,LICENSE"
}
Expand Down
12,865 changes: 5,357 additions & 7,508 deletions package-lock.json

Large diffs are not rendered by default.

33 changes: 19 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"package.json"
],
"scripts": {
"build": "cross-env TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack --progress --config webpack/webpack.prod.ts",
"build-gh-pages": "cross-env TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack --config webpack/webpack.ghpages.ts",
"start": "cross-env TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack serve --config webpack/webpack.dev.ts",
"build": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
"build-gh-pages": "npm run build -- --sourcemap inline",
"start": "vite",
"fetch-deps": "node --loader=ts-node/esm ./util/fetch_deps.ts",
"tsc-no-emit": "tsc --noEmit",
"lint": "run-s lint:**",
Expand Down Expand Up @@ -59,8 +59,14 @@
"@babel/preset-typescript": "^7.14.5",
"@dprint/json": "^0.16.0",
"@dprint/typescript": "^0.75.0",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-image": "^3.0.3",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-typescript": "^12.1.1",
"@rollup/plugin-virtual": "^3.0.2",
"@types/argparse": "^1.0.38",
"@types/chai": "^4.3.1",
"@types/dedent": "^0.7.2",
"@types/inquirer": "^9.0.7",
"@types/inquirer-fuzzy-path": "^2.3.9",
"@types/is-ci": "^3.0.0",
Expand All @@ -71,18 +77,16 @@
"@types/node": "^20.14.12",
"@types/node-fetch": "^2.5.10",
"@types/tar-fs": "^2.0.0",
"@types/webpack": "^5.28.0",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0",
"@typescript-eslint/utils": "^7.11.0",
"@web/rollup-plugin-html": "^2.3.0",
"babel-loader": "^8.2.2",
"chai": "^4.3.6",
"chalk": "^2.4.2",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^10.2.4",
"cross-env": "^7.0.3",
"css-loader": "^6.5.1",
"css-minimizer-webpack-plugin": "^3.4.1",
"dedent": "^1.5.3",
"dprint": "^0.40.2",
"eslint": "^8.56.0",
"eslint-config-google": "^0.14.0",
Expand All @@ -94,9 +98,7 @@
"eslint-plugin-tsc": "^2.0.0",
"eslint-plugin-unicorn": "^44.0.2",
"fast-levenshtein": "^3.0.0",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"fs-extra": "^10.1.0",
"html-webpack-plugin": "^5.5.0",
"husky": "^4.2.5",
"is-ci": "^3.0.1",
"jsdom-global": "^3.0.2",
Expand All @@ -112,18 +114,21 @@
"postcss": "^8.3.5",
"proxy-agent": "^5.0.0",
"recast": "^0.20.4",
"rollup": "^4.28.1",
"rollup-plugin-cleaner": "^1.0.0",
"rollup-plugin-css-only": "^4.5.2",
"style-loader": "^3.3.1",
"stylelint": "^14.8.2",
"stylelint-config-standard": "^25.0.0",
"systemjs": "^6.15.1",
"tar-fs": "^2.1.1",
"ts-loader": "^9.3.0",
"ts-node": "^10.9.2",
"tsconfig-paths": "^3.9.0",
"typescript": "^5.1.6",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.9.0",
"webpack-merge": "^5.8.0"
"vite": "^6.0.0",
"vite-plugin-checker": "^0.8.0",
"vite-plugin-minify": "^2.1.0",
"vite-plugin-static-copy": "^2.2.0"
},
"engines": {
"node": ">=20.10.0"
Expand Down
90 changes: 90 additions & 0 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import commonjs from '@rollup/plugin-commonjs';
import nodeResolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import image from '@rollup/plugin-image';
import { rollupPluginHTML as html } from '@web/rollup-plugin-html';
import { defineConfig } from 'rollup';
import cleaner from 'rollup-plugin-cleaner'
import css from 'rollup-plugin-css-only';

export default defineConfig({
plugins: [
typescript(),
nodeResolve(),
commonjs(),
cleaner({ targets: ['dist'] }),
image(),
css(),
html({
input: [
'ui/config/config.html',
// 'util/coverage/coverage.html',
// 'ui/dps/rdmty/dps.html',
// 'ui/dps/xephero/xephero-cactbot.html',
'ui/eureka/eureka.html',
'ui/jobs/jobs.html',
'ui/oopsyraidsy/oopsyraidsy.html',
'ui/oopsyraidsy/oopsy_summary.html',
'ui/oopsyraidsy/oopsy_viewer.html',
'ui/pullcounter/pullcounter.html',
'ui/radar/radar.html',
'ui/raidboss/raidboss.html',
'ui/raidboss/raidboss_alerts_only.html',
'ui/raidboss/raidboss_timeline_only.html',
'ui/raidboss/raidboss_silent.html',
'ui/raidboss/raidemulator.html',
'util/logtools/splitter.html',
'ui/test/test.html',
],
extractAssets: false,
rootDir: '.',
flattenOutput: false,
}),
],
output: {
dir: 'dist',
format: 'es',
sourcemap: 'inline',
chunkFileNames: '[name].bundle.js',
assetFileNames: '[name][extname]',
manualChunks: (id) => {
if (/ui\/raidboss\/data\/.*(?:ts|js|txt\?raw)$/.test(id) || /^\0?timeline:/.test(id)) {
return 'ui/common/raidboss_data';
}
if (/ui\/oopsyraidsy\/data\/.*(?:ts|js)$/.test(id)) {
return 'ui/common/oopsyraidsy_data';
}
if (/ui\/raidboss\/(?:raidemulator.ts$|emulator\/.*(?:ts|js)$)/.test(id)) {
return 'ui/raidboss/raidemulator';
}
if (/resources\/.*\.(?:ts|js)$/.test(id) || id.includes('node_modules')) {
return 'ui/common/vendor';
}
if (!/\.(?:ts|js)$/.test(id)) {
return;
}

const modules = {
'ui/config/': 'ui/config/config',
'util/coverage/': 'util/coverage/coverage',
'ui/dps/rdmty/': 'ui/dps/rdmty/dps',
'ui/dps/xephero/': 'ui/dps/xephero/xephero',
'ui/eureka/': 'ui/eureka/eureka',
'ui/jobs/': 'ui/jobs/jobs',
'ui/oopsyraidsy/': 'ui/oopsyraidsy/oopsyraidsy',
'ui/pullcounter/': 'ui/pullcounter/pullcounter',
'ui/radar/': 'ui/radar/radar',
'ui/raidboss/': 'ui/raidboss/raidboss',
'util/logtools/': 'util/logtools/web_splitter',
'ui/test/': 'ui/test/test',
};

for (const [match, module] of Object.entries(modules)) {
if (id.includes(match)) {
console.log(id, module);
return module;
}
}
},
}
});
5 changes: 3 additions & 2 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
"./resources",
"./util",
"./test",
"./webpack",
"./user",
"./.github/scripts",
"./eslint",
"./.eslintrc.cjs",
"./.mocharc.cjs"
"./.mocharc.cjs",
"./vite",
"./vite.config.ts"
],
"exclude": [
"./dist"
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"**/*.spec.ts"
],
"references": [
{ "path": "./tsconfig.node.json" },
{ "path": "./tsconfig.webpack.json" }
{ "path": "./tsconfig.node.json" }
]
}
4 changes: 3 additions & 1 deletion tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
},
"include": [
"./util",
"./test"
"./test",
"./vite",
"./vite.config.ts"
],
"references": [{ "path": "./tsconfig.json" }]
}
20 changes: 0 additions & 20 deletions tsconfig.webpack.json

This file was deleted.

4 changes: 4 additions & 0 deletions types/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* eslint-disable spaced-comment */
/// <reference types="vite/client" />

export {};
14 changes: 0 additions & 14 deletions types/images.d.ts

This file was deleted.

4 changes: 2 additions & 2 deletions types/manifest.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
declare module '*/raidboss_manifest.txt' {
declare module 'raidboss.manifest' {
const raidbossFileData: import('./trigger').RaidbossFileData;
export default raidbossFileData;
}

declare module '*/oopsy_manifest.txt' {
declare module 'oopsy.manifest' {
const oopsyFileData: import('./oopsy').OopsyFileData;
export default oopsyFileData;
}
2 changes: 2 additions & 0 deletions ui/config/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<head>
<title>Cactbot Configuration</title>
<meta charset="utf-8" />

<script type="module" src="./config.ts"></script>
</head>
<body>
<div id="butter-margin" class="hidden">
Expand Down
2 changes: 2 additions & 0 deletions ui/dps/rdmty/dps.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<script src="https://unpkg.com/[email protected]/lodash.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/react.min.js"></script>
<script src="../../../user/rdmty.js"></script>

<script type="module" src="./dps.js"></script>
</head>
<body>
<div id="container"></div>
Expand Down
2 changes: 2 additions & 0 deletions ui/dps/xephero/xephero-cactbot.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/jquery.min.js"></script>

<script src="../../../user/xephero.js"></script>

<script type="module" src="./xephero.js"></script>
</head>
<body>
<ol id="overlaysource">
Expand Down
2 changes: 2 additions & 0 deletions ui/jobs/jobs.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<head>
<meta charset="utf-8" />
<title>Cactbot Jobs</title>

<script type="module" src="./jobs.ts"></script>
</head>
<body>
<div id="container">
Expand Down
2 changes: 0 additions & 2 deletions ui/oopsyraidsy/data/oopsy_manifest.txt

This file was deleted.

2 changes: 2 additions & 0 deletions ui/oopsyraidsy/oopsy_summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/solid.min.css"
/>

<script type="module" src="./oopsy_summary.ts"></script>
</head>
<body>
<div id="container">
Expand Down
2 changes: 2 additions & 0 deletions ui/oopsyraidsy/oopsy_viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/solid.min.css"
/>

<script type="module" src="./oopsy_viewer.ts"></script>
</head>
<body>
<div id="filedrop"></div>
Expand Down
3 changes: 2 additions & 1 deletion ui/oopsyraidsy/oopsy_viewer.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import oopsyFileData from 'oopsy.manifest';

import { UnreachableCode } from '../../resources/not_reached';
import { callOverlayHandler } from '../../resources/overlay_plugin_api';
import PartyTracker from '../../resources/party';
import UserConfig from '../../resources/user_config';
import { LocaleText } from '../../types/trigger';

import { DamageTracker, earlyPullTriggerId } from './damage_tracker';
import oopsyFileData from './data/oopsy_manifest.txt';
import { MistakeCollector } from './mistake_collector';
import defaultOptions, { OopsyOptions } from './oopsy_options';
import { OopsySummaryList, OopsySummaryTable } from './oopsy_summary_list';
Expand Down
2 changes: 2 additions & 0 deletions ui/oopsyraidsy/oopsyraidsy.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/solid.min.css"
/>

<script type="module" src="./oopsyraidsy.ts"></script>
</head>
<body>
<div id="container">
Expand Down
3 changes: 2 additions & 1 deletion ui/oopsyraidsy/oopsyraidsy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import oopsyFileData from 'oopsy.manifest';

import { UnreachableCode } from '../../resources/not_reached';
import { addOverlayListener, callOverlayHandler } from '../../resources/overlay_plugin_api';
import PartyTracker from '../../resources/party';
import UserConfig from '../../resources/user_config';
import { OopsyMistakeType } from '../../types/oopsy';

import { DamageTracker } from './damage_tracker';
import oopsyFileData from './data/oopsy_manifest.txt';
import { MistakeCollector } from './mistake_collector';
import { OopsyLiveList } from './oopsy_live_list';
import defaultOptions from './oopsy_options';
Expand Down
Loading
Loading