Skip to content

Commit dda35a4

Browse files
Remove Webpack and speed up web builds (#3218)
Use Vite and turbopack instead of webpack
1 parent d21c021 commit dda35a4

20 files changed

Lines changed: 1294 additions & 897 deletions

File tree

eslint.config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ const disabledTypeCheckConfig: ConfigWithExtends = {
138138
"**/docusaurus.config.mts",
139139
"**/mdx-components.tsx",
140140
"**/eslintConfig.ts",
141+
"**/vite.config.ts",
141142
"eslint.config.mts",
142143
"prettier.config.cjs",
143144
"typings/**",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"lint:ts": "eslint packages",
2323
"lint:prettier": "prettier --check .",
2424
"lint": "pnpm run lint:meta && pnpm run lint:syncpack && pnpm run lint:ts",
25-
"init-vscode-sandbox": "pnpm -F=@cursorless/cursorless-vscode init-launch-sandbox",
25+
"init-vscode-sandbox": "pnpm -F @cursorless/cursorless-vscode init-launch-sandbox",
2626
"meta-updater": "env NODE_OPTIONS='--import=tsx --conditions=cursorless:bundler' meta-updater",
2727
"preinstall": "npx only-allow pnpm",
2828
"test-compile": "tsc --build",
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
<title>Cursorless Cheatsheet</title>
66

77
<meta name="viewport" content="width=device-width, initial-scale=1" />
8-
<link rel="icon" type="image/x-icon" href="favicon.ico" />
8+
<link rel="icon" type="image/x-icon" href="./src/favicon.ico" />
99
<script id="cheatsheet-data">
1010
// Dummy data for use in debugging
11-
document.cheatsheetInfo = <%= fakeCheatsheetInfo %>;
11+
document.cheatsheetInfo = __FAKE_CHEATSHEET_INFO__;
1212
</script>
1313
</head>
14-
<body class="<%= bodyClasses %>">
14+
<body class="__BODY_CLASSES__">
1515
<div id="root"></div>
16+
<script type="module" src="./src/index.tsx"></script>
1617
</body>
1718
</html>

packages/cheatsheet-local/package.json

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,30 @@
2222
"compile": "tsc --build",
2323
"watch": "tsc --build --watch",
2424
"build": "pnpm build:prod",
25-
"build:dev": "pnpm webpack --mode=development",
26-
"build:prod": "pnpm webpack --mode=production --node-env=production",
27-
"webpack": "env NODE_OPTIONS=--loader=ts-node/esm webpack --config ./src/webpack.config.ts",
25+
"build:dev": "vite build --mode development",
26+
"build:prod": "vite build --mode production",
2827
"clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build"
2928
},
3029
"dependencies": {
3130
"@cursorless/cheatsheet": "workspace:*",
3231
"react": "^19.2.4",
33-
"react-dom": "^19.2.4"
32+
"react-dom": "^19.2.4",
33+
"tslib": "^2.8.1"
3434
},
3535
"devDependencies": {
36-
"@effortlessmotion/html-webpack-inline-source-plugin": "^1.0.3",
3736
"@tailwindcss/postcss": "^4.2.1",
3837
"@testing-library/dom": "^10.4.1",
3938
"@testing-library/react": "^16.3.2",
4039
"@types/jest": "^30.0.0",
4140
"@types/node": "^24.12.0",
4241
"@types/react": "^19.2.14",
4342
"@types/react-dom": "^19.2.3",
44-
"@types/webpack": "^5.28.5",
45-
"css-loader": "^7.1.4",
46-
"html-webpack-plugin": "^5.6.6",
43+
"@vitejs/plugin-react": "^5.1.0",
4744
"jest": "^30.2.0",
4845
"postcss": "^8.5.8",
49-
"postcss-loader": "^8.2.1",
50-
"style-loader": "^4.0.0",
5146
"tailwindcss": "^4.2.1",
52-
"ts-loader": "^9.5.4",
53-
"ts-node": "^10.9.2",
5447
"typescript": "^5.9.3",
55-
"webpack": "^5.105.4",
56-
"webpack-cli": "^6.0.1",
57-
"webpack-dev-server": "^5.2.3"
48+
"vite": "^7.1.7",
49+
"vite-plugin-singlefile": "^2.3.0"
5850
}
5951
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@import "tailwindcss";
22

3-
@config "../tailwind.config.js";
3+
@config "../tailwind.config.mjs";

packages/cheatsheet-local/src/webpack.config.ts

Lines changed: 0 additions & 62 deletions
This file was deleted.
File renamed without changes.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {
2+
cheatsheetBodyClasses,
3+
fakeCheatsheetInfo,
4+
} from "@cursorless/cheatsheet";
5+
import react from "@vitejs/plugin-react";
6+
import { defineConfig, type PluginOption } from "vite";
7+
import { viteSingleFile } from "vite-plugin-singlefile";
8+
9+
export default defineConfig(() => {
10+
return {
11+
build: {
12+
outDir: "dist",
13+
14+
rollupOptions: {
15+
input: {
16+
index: "./index.html",
17+
},
18+
},
19+
},
20+
21+
plugins: [react(), viteSingleFile(), injectCheatsheetTemplateData()],
22+
};
23+
});
24+
25+
function injectCheatsheetTemplateData(): PluginOption {
26+
return {
27+
name: "inject-cheatsheet-template-data",
28+
transformIndexHtml(html) {
29+
return html
30+
.replaceAll("__BODY_CLASSES__", cheatsheetBodyClasses)
31+
.replaceAll(
32+
"__FAKE_CHEATSHEET_INFO__",
33+
JSON.stringify(fakeCheatsheetInfo),
34+
);
35+
},
36+
};
37+
}

packages/cursorless-org-docs/docusaurus.config.mts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ const config: Config = {
8787
tagline: "Structural voice coding at the speed of thought",
8888
url: "https://www.cursorless.org",
8989
baseUrl: "/docs/",
90+
onBrokenLinks: "throw",
91+
onBrokenAnchors: "throw",
92+
trailingSlash: true,
93+
94+
future: {
95+
v4: {
96+
removeLegacyPostBuildHeadAttribute: true,
97+
},
98+
experimental_faster: true,
99+
},
100+
90101
stylesheets: [
91102
// Icons generated with https://favicon.io/favicon-generator/
92103
{
@@ -119,9 +130,6 @@ const config: Config = {
119130
},
120131
{ rel: "shortcut icon", href: "/favicon.ico?v=1" },
121132
],
122-
onBrokenLinks: "throw",
123-
onBrokenAnchors: "throw",
124-
trailingSlash: true,
125133

126134
markdown: {
127135
hooks: {
@@ -151,6 +159,7 @@ const config: Config = {
151159
},
152160
],
153161
],
162+
154163
plugins: [
155164
"./src/plugins/tailwind-plugin.ts",
156165
"./src/plugins/scope-tests-plugin.ts",

packages/cursorless-org-docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"@cursorless/common": "workspace:*",
4949
"@docsearch/react": "^4.6.0",
5050
"@docusaurus/core": "^3.9.2",
51+
"@docusaurus/faster": "^3.9.2",
5152
"@docusaurus/preset-classic": "^3.9.2",
5253
"@docusaurus/theme-classic": "^3.9.2",
5354
"@docusaurus/theme-common": "^3.9.2",

0 commit comments

Comments
 (0)