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

Allow customising the Vite config #1465

Merged
merged 8 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
"include": ["vite.config.ts", "./src/ext-src/vite.config.ts"]
}
34 changes: 24 additions & 10 deletions waspc/data/Generator/templates/react-app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
{{={= =}=}}
/// <reference types="vitest" />
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { mergeConfig } from "vite";
import react from "@vitejs/plugin-react-swc";

// https://vitejs.dev/config/
export default defineConfig({
{=# customViteConfig.isDefined =}
{=& customViteConfig.importStatement =}
const _waspUserProvidedConfig = {=& customViteConfig.importIdentifier =}
{=/ customViteConfig.isDefined =}
{=^ customViteConfig.isDefined =}
const _waspUserProvidedConfig = {};
{=/ customViteConfig.isDefined =}

const defaultViteConfig = {
plugins: [react()],
server: {
port: 3000,
host: '0.0.0.0',
host: "0.0.0.0",
open: true,
},
envPrefix: 'REACT_APP_',
envPrefix: "REACT_APP_",
build: {
outDir: 'build',
outDir: "build",
},
test: {
environment: 'jsdom',
setupFiles: ['./src/test/vitest/setup.ts'],
environment: "jsdom",
setupFiles: ["./src/test/vitest/setup.ts"],
},
})
};

// https://vitejs.dev/config/
export default mergeConfig(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the built-in Vite helper to merge the objects.

defaultViteConfig,
_waspUserProvidedConfig
);

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions waspc/examples/custom-vite-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/.wasp/

# We ignore env files recognized and used by Wasp.
.env.server
.env.client

# To be extra safe, we by default ignore any files with `.env` extension in them.
# If this is too agressive for you, consider allowing specific files with `!` operator,
# or modify/delete these two lines.
*.env
*.env.*
1 change: 1 addition & 0 deletions waspc/examples/custom-vite-demo/.wasproot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File marking the root of Wasp project.
11 changes: 11 additions & 0 deletions waspc/examples/custom-vite-demo/main.wasp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
app customViteDemo {
wasp: {
version: "^0.11.5"
},
title: "custom-vite-demo"
}

route RootRoute { path: "/", to: MainPage }
page MainPage {
component: import Main from "@client/MainPage.jsx"
}
3 changes: 3 additions & 0 deletions waspc/examples/custom-vite-demo/src/.waspignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore editor tmp files
**/*~
**/#*#
Loading
Loading