cleanup(bundling): remove unnecessary files and targets for Vite apps… (#13456)
This commit is contained in:
parent
82478b8fd9
commit
cf7ad73165
@ -67,7 +67,7 @@
|
|||||||
},
|
},
|
||||||
"includeLib": {
|
"includeLib": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Add a library build option.",
|
"description": "Add a library build option and skip the server option.",
|
||||||
"default": false,
|
"default": false,
|
||||||
"x-prompt": "Does this project contain a buildable library?"
|
"x-prompt": "Does this project contain a buildable library?"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -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>
|
|
||||||
@ -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>
|
|
||||||
);
|
|
||||||
<% } %>
|
|
||||||
@ -40,7 +40,10 @@ export async function viteConfigurationGenerator(tree: Tree, schema: Schema) {
|
|||||||
tasks.push(initTask);
|
tasks.push(initTask);
|
||||||
|
|
||||||
addOrChangeBuildTarget(tree, schema, buildTarget);
|
addOrChangeBuildTarget(tree, schema, buildTarget);
|
||||||
addOrChangeServeTarget(tree, schema, serveTarget);
|
|
||||||
|
if (!schema.includeLib) {
|
||||||
|
addOrChangeServeTarget(tree, schema, serveTarget);
|
||||||
|
}
|
||||||
|
|
||||||
writeViteConfig(tree, schema);
|
writeViteConfig(tree, schema);
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
},
|
},
|
||||||
"includeLib": {
|
"includeLib": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Add a library build option.",
|
"description": "Add a library build option and skip the server option.",
|
||||||
"default": false,
|
"default": false,
|
||||||
"x-prompt": "Does this project contain a buildable library?"
|
"x-prompt": "Does this project contain a buildable library?"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -150,23 +150,7 @@ export function addOrChangeBuildTarget(
|
|||||||
options: buildOptions,
|
options: buildOptions,
|
||||||
configurations: {
|
configurations: {
|
||||||
development: {},
|
development: {},
|
||||||
production: options.includeLib
|
production: {},
|
||||||
? {}
|
|
||||||
: {
|
|
||||||
fileReplacements: [
|
|
||||||
{
|
|
||||||
replace: joinPathFragments(
|
|
||||||
project.sourceRoot,
|
|
||||||
'environments/environment.ts'
|
|
||||||
),
|
|
||||||
with: joinPathFragments(
|
|
||||||
project.sourceRoot,
|
|
||||||
'environments/environment.prod.ts'
|
|
||||||
),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
sourceMap: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -408,7 +392,9 @@ export function writeViteConfig(tree: Tree, options: Schema) {
|
|||||||
},`
|
},`
|
||||||
: ``;
|
: ``;
|
||||||
|
|
||||||
const serverOption = `
|
const serverOption = options.includeLib
|
||||||
|
? ''
|
||||||
|
: `
|
||||||
server:{
|
server:{
|
||||||
port: 4200,
|
port: 4200,
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user