-
Notifications
You must be signed in to change notification settings - Fork 905
chore: Use Vite instead of Webpack for development #4156
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fda44bf
chore: Use Vite instead of Webpack
BrunoQuaresma 62d1223
Remove console.log
BrunoQuaresma 376fec7
Fix vite
BrunoQuaresma a82afdf
Make all routers lazy
BrunoQuaresma fe2e85a
Merge branch 'bq/improve-load-time' into try-vite
BrunoQuaresma 1ae207b
Merge branch 'main' of github.com:coder/coder into try-vite
BrunoQuaresma 2c9544e
Remove module
BrunoQuaresma 67b5105
Minor improvements
BrunoQuaresma 835c5f3
Minor improvements
BrunoQuaresma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
|
||
<!-- | ||
▄█▀ ▀█▄ | ||
▄▄ ▀▀▀ █▌ ██▀▀█▄ ▐█ | ||
▄▄██▀▀█▄▄▄ ██ ██ █▀▀█ ▐█▀▀██ ▄█▀▀█ █▀▀ | ||
█▌ ▄▌ ▐█ █▌ ▀█▄▄▄█▌ █ █ ▐█ ██ ██▀▀ █ | ||
██████▀▄█ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀▀ ▀▀▀▀ ▀ | ||
--> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#17172E" /> | ||
<meta name="application-name" content="Coder2" /> | ||
<meta property="og:type" content="website" /> | ||
<meta property="csp-nonce" content="{{ .CSP.Nonce }}" /> | ||
<meta property="csrf-token" content="{{ .CSRF.Token }}" /> | ||
<meta | ||
id="api-response" | ||
data-statuscode="{{ .APIResponse.StatusCode }}" | ||
data-message="{{ .APIResponse.Message }}" | ||
/> | ||
<!-- We need to set data-react-helmet to be able to override it in the workspace page --> | ||
<link | ||
rel="alternate icon" | ||
type="image/png" | ||
href="/favicons/favicon.png" | ||
data-react-helmet="true" | ||
/> | ||
<link rel="icon" type="image/svg+xml" href="/favicons/favicon.svg" data-react-helmet="true" /> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="./src/Main.tsx"></script> | ||
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
"check:all": "yarn format:check && yarn lint && yarn test", | ||
"chromatic": "chromatic", | ||
"dev": "webpack-dev-server --config=webpack.dev.ts", | ||
"dev:vite": "vite", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like that you're leaving webpack in and encouraging folks to try vite. Seems like the right move and then when we're confident Vite works, we can remove webpack 👍🏼 |
||
"format:check": "prettier --check '**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'", | ||
"format:types": "prettier --write 'src/api/typesGenerated.ts'", | ||
"format:write": "prettier --write '**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'", | ||
|
@@ -34,6 +35,7 @@ | |
"@material-ui/icons": "4.5.1", | ||
"@material-ui/lab": "4.0.0-alpha.42", | ||
"@testing-library/react-hooks": "8.0.1", | ||
"@vitejs/plugin-react": "2.1.0", | ||
"@xstate/inspect": "0.6.5", | ||
"@xstate/react": "3.0.1", | ||
"axios": "0.26.1", | ||
|
@@ -63,6 +65,7 @@ | |
"tzdata": "1.0.30", | ||
"ua-parser-js": "1.0.2", | ||
"uuid": "9.0.0", | ||
"vite": "3.1.3", | ||
"xstate": "4.33.5", | ||
"xterm": "4.19.0", | ||
"xterm-addon-fit": "0.5.0", | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,3 +59,5 @@ export const LoginPage: React.FC = () => { | |
) | ||
} | ||
} | ||
|
||
export default LoginPage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,5 @@ export const TemplatesPage: React.FC = () => { | |
</> | ||
) | ||
} | ||
|
||
export default TemplatesPage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,5 @@ export const AccountPage: React.FC = () => { | |
</Section> | ||
) | ||
} | ||
|
||
export default AccountPage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,5 @@ export const SecurityPage: React.FC = () => { | |
</Section> | ||
) | ||
} | ||
|
||
export default SecurityPage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,5 @@ export const CreateUserPage: React.FC = () => { | |
</Margins> | ||
) | ||
} | ||
|
||
export default CreateUserPage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,3 +195,5 @@ export const UsersPage: FC<{ children?: ReactNode }> = () => { | |
</> | ||
) | ||
} | ||
|
||
export default UsersPage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,5 @@ export const WorkspaceBuildPage: FC = () => { | |
</> | ||
) | ||
} | ||
|
||
export default WorkspaceBuildPage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,3 +154,5 @@ const useStyles = makeStyles((theme) => ({ | |
margin: theme.spacing(2), | ||
}, | ||
})) | ||
|
||
export default WorkspacePage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import react from "@vitejs/plugin-react" | ||
import path from "path" | ||
import { defineConfig } from "vite" | ||
|
||
export default defineConfig({ | ||
plugins: [react()], | ||
publicDir: path.resolve(__dirname, "./static"), | ||
build: { | ||
outDir: path.resolve(__dirname, "./out"), | ||
}, | ||
define: { | ||
"process.env": process.env, | ||
}, | ||
server: { | ||
port: process.env.PORT ? Number(process.env.PORT) : 8080, | ||
proxy: { | ||
"/api": { | ||
target: process.env.CODER_HOST || "http://localhost:3000", | ||
ws: true, | ||
secure: process.env.NODE_ENV === "production", | ||
}, | ||
}, | ||
}, | ||
resolve: { | ||
BrunoQuaresma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
alias: { | ||
api: path.resolve(__dirname, "./src/api"), | ||
components: path.resolve(__dirname, "./src/components"), | ||
hooks: path.resolve(__dirname, "./src/hooks"), | ||
i18n: path.resolve(__dirname, "./src/i18n"), | ||
pages: path.resolve(__dirname, "./src/pages"), | ||
testHelpers: path.resolve(__dirname, "./src/testHelpers"), | ||
theme: path.resolve(__dirname, "./src/theme"), | ||
util: path.resolve(__dirname, "./src/util"), | ||
xServices: path.resolve(__dirname, "./src/xServices"), | ||
}, | ||
}, | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Why do we have to add this? (Or is this a file move? hard to tell)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vite requires the HTML file to be in the root.