cleanup(bundling): remove unnecessary files and targets for Vite apps… (#13456)

This commit is contained in:
Jack Hsu 2022-11-28 17:08:37 -05:00 committed by GitHub
parent 82478b8fd9
commit cf7ad73165
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 55 deletions

View File

@ -67,7 +67,7 @@
},
"includeLib": {
"type": "boolean",
"description": "Add a library build option.",
"description": "Add a library build option and skip the server option.",
"default": false,
"x-prompt": "Does this project contain a buildable library?"
},

View File

@ -1,15 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title><%= className %> Demo</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
<div id="root"></div>
<script type="module" src="./src/demo.tsx"></script>
</body>
</html>

View File

@ -1,19 +0,0 @@
/*
* This a a demo file that can be helpful when developing components by serving and interacting with them in the browser.
*/
<% if (component) { %>
import * as ReactDOM from 'react-dom/client';
import { <%= className %> } from './index';
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
root.render(
<<%= className %> />
);
<% } else { %>
import * as ReactDOM from 'react-dom/client';
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
root.render(
<h1><%= className %> Demo</h1>
);
<% } %>

View File

@ -40,7 +40,10 @@ export async function viteConfigurationGenerator(tree: Tree, schema: Schema) {
tasks.push(initTask);
addOrChangeBuildTarget(tree, schema, buildTarget);
if (!schema.includeLib) {
addOrChangeServeTarget(tree, schema, serveTarget);
}
writeViteConfig(tree, schema);

View File

@ -18,7 +18,7 @@
},
"includeLib": {
"type": "boolean",
"description": "Add a library build option.",
"description": "Add a library build option and skip the server option.",
"default": false,
"x-prompt": "Does this project contain a buildable library?"
},

View File

@ -150,23 +150,7 @@ export function addOrChangeBuildTarget(
options: buildOptions,
configurations: {
development: {},
production: options.includeLib
? {}
: {
fileReplacements: [
{
replace: joinPathFragments(
project.sourceRoot,
'environments/environment.ts'
),
with: joinPathFragments(
project.sourceRoot,
'environments/environment.prod.ts'
),
},
],
sourceMap: false,
},
production: {},
},
};
}
@ -408,7 +392,9 @@ export function writeViteConfig(tree: Tree, options: Schema) {
},`
: ``;
const serverOption = `
const serverOption = options.includeLib
? ''
: `
server:{
port: 4200,
host: 'localhost',