diff --git a/docs/generated/packages/vite.json b/docs/generated/packages/vite.json
index 9fe8a35986f7ea..f5c32e3714156d 100644
--- a/docs/generated/packages/vite.json
+++ b/docs/generated/packages/vite.json
@@ -161,29 +161,18 @@
"description": "Path to the proxy configuration file.",
"x-completion-type": "file"
},
- "port": {
- "type": "number",
- "description": "Port to listen on.",
- "default": 4200
- },
+ "port": { "type": "number", "description": "Port to listen on." },
"host": {
"description": "Specify which IP addresses the server should listen on.",
- "default": "localhost",
"oneOf": [{ "type": "boolean" }, { "type": "string" }]
},
- "https": {
- "type": "boolean",
- "description": "Serve using HTTPS.",
- "default": false
- },
+ "https": { "type": "boolean", "description": "Serve using HTTPS." },
"hmr": {
"description": "Enable hot module replacement. For more options, use the 'hmr' option in the Vite configuration file.",
- "type": "boolean",
- "default": true
+ "type": "boolean"
},
"open": {
"description": "Automatically open the app in the browser on server start. When the value is a string, it will be used as the URL's pathname.",
- "default": false,
"oneOf": [{ "type": "boolean" }, { "type": "string" }]
},
"cors": {
@@ -198,12 +187,10 @@
"mode": {
"type": "string",
"description": "Mode to run the server in.",
- "enum": ["production", "development"],
- "default": "development"
+ "enum": ["production", "development"]
},
"clearScreen": {
"description": "Set to false to prevent Vite from clearing the terminal screen when logging certain messages.",
- "default": true,
"type": "boolean"
}
},
@@ -312,12 +299,10 @@
},
"sourcemap": {
"description": "Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.",
- "default": true,
"oneOf": [{ "type": "boolean" }, { "type": "string" }]
},
"minify": {
"description": "Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.",
- "default": "esbuild",
"oneOf": [{ "type": "boolean" }, { "type": "string" }]
},
"manifest": {
@@ -336,8 +321,7 @@
"mode": {
"type": "string",
"description": "Mode to run the build in.",
- "enum": ["production", "development"],
- "default": "production"
+ "enum": ["production", "development"]
}
},
"definitions": {
diff --git a/packages/vite/src/executors/build/schema.json b/packages/vite/src/executors/build/schema.json
index e788006f18989e..1dff5ab8548221 100644
--- a/packages/vite/src/executors/build/schema.json
+++ b/packages/vite/src/executors/build/schema.json
@@ -70,7 +70,6 @@
},
"sourcemap": {
"description": "Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.",
- "default": true,
"oneOf": [
{
"type": "boolean"
@@ -82,7 +81,6 @@
},
"minify": {
"description": "Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.",
- "default": "esbuild",
"oneOf": [
{
"type": "boolean"
@@ -122,8 +120,7 @@
"mode": {
"type": "string",
"description": "Mode to run the build in.",
- "enum": ["production", "development"],
- "default": "production"
+ "enum": ["production", "development"]
}
},
"definitions": {
diff --git a/packages/vite/src/executors/dev-server/schema.json b/packages/vite/src/executors/dev-server/schema.json
index 08b793904553bd..0bbc1a9bb11048 100644
--- a/packages/vite/src/executors/dev-server/schema.json
+++ b/packages/vite/src/executors/dev-server/schema.json
@@ -27,12 +27,10 @@
},
"port": {
"type": "number",
- "description": "Port to listen on.",
- "default": 4200
+ "description": "Port to listen on."
},
"host": {
"description": "Specify which IP addresses the server should listen on.",
- "default": "localhost",
"oneOf": [
{
"type": "boolean"
@@ -44,17 +42,14 @@
},
"https": {
"type": "boolean",
- "description": "Serve using HTTPS.",
- "default": false
+ "description": "Serve using HTTPS."
},
"hmr": {
"description": "Enable hot module replacement. For more options, use the 'hmr' option in the Vite configuration file.",
- "type": "boolean",
- "default": true
+ "type": "boolean"
},
"open": {
"description": "Automatically open the app in the browser on server start. When the value is a string, it will be used as the URL's pathname.",
- "default": false,
"oneOf": [
{
"type": "boolean"
@@ -76,12 +71,10 @@
"mode": {
"type": "string",
"description": "Mode to run the server in.",
- "enum": ["production", "development"],
- "default": "development"
+ "enum": ["production", "development"]
},
"clearScreen": {
"description": "Set to false to prevent Vite from clearing the terminal screen when logging certain messages.",
- "default": true,
"type": "boolean"
}
},
diff --git a/packages/vite/src/utils/generator-utils.ts b/packages/vite/src/utils/generator-utils.ts
index d83e4f73861ab2..aa4ec043ababd0 100644
--- a/packages/vite/src/utils/generator-utils.ts
+++ b/packages/vite/src/utils/generator-utils.ts
@@ -388,6 +388,7 @@ export function writeViteConfig(tree: Tree, options: Schema) {
// Configuration for building your library.
// See: https://vitejs.dev/guide/build.html#library-mode
build: {
+ mode: 'production',
lib: {
// Could also be a dictionary or array of multiple entry points.
entry: 'src/index.ts',
@@ -406,7 +407,17 @@ export function writeViteConfig(tree: Tree, options: Schema) {
}]
}
},`
- : '';
+ : `
+ build: {
+ mode: 'production',
+ },`;
+
+ const serverOption = `
+ server:{
+ port: 4200,
+ mode: 'development',
+ host: 'localhost',
+ },`;
switch (options.uiFramework) {
case 'react':
@@ -422,6 +433,7 @@ ${options.includeVitest ? '/// ' : ''}
}
export default defineConfig({
+ ${serverOption}
plugins: [
${options.includeLib ? dtsPlugin : ''}
react(),
@@ -447,6 +459,7 @@ ${options.includeVitest ? '/// ' : ''}
}
export default defineConfig({
+ ${serverOption}
plugins: [
${options.includeLib ? dtsPlugin : ''}
tsconfigPaths({
diff --git a/packages/vite/src/utils/options-utils.ts b/packages/vite/src/utils/options-utils.ts
index 577878a8f26efc..bedaa7ea01c6f1 100644
--- a/packages/vite/src/utils/options-utils.ts
+++ b/packages/vite/src/utils/options-utils.ts
@@ -79,7 +79,7 @@ export async function getUserConfig(
): Promise {
const baseUserConfig: UserConfigFn = (await defineConfig(() => {
return {
- base: options.baseHref ?? '/',
+ base: options.baseHref ?? undefined,
root: projectRoot,
tsConfig: normalizeTsConfigPath(options.tsConfig, context.root),
};