feat(web): add generateIndexHtml option to web build executor (#5843)
This commit is contained in:
parent
d3c45b32b9
commit
12ee3bce97
@ -102,6 +102,14 @@ Type: `string`
|
|||||||
|
|
||||||
The file to replace with.
|
The file to replace with.
|
||||||
|
|
||||||
|
### generateIndexHtml
|
||||||
|
|
||||||
|
Default: `true`
|
||||||
|
|
||||||
|
Type: `boolean`
|
||||||
|
|
||||||
|
Generates `index.html` file to the output path. This can be turned off if using a webpack plugin to generate HTML such as `html-webpack-plugin`
|
||||||
|
|
||||||
### index
|
### index
|
||||||
|
|
||||||
Type: `string`
|
Type: `string`
|
||||||
|
|||||||
@ -103,6 +103,14 @@ Type: `string`
|
|||||||
|
|
||||||
The file to replace with.
|
The file to replace with.
|
||||||
|
|
||||||
|
### generateIndexHtml
|
||||||
|
|
||||||
|
Default: `true`
|
||||||
|
|
||||||
|
Type: `boolean`
|
||||||
|
|
||||||
|
Generates `index.html` file to the output path. This can be turned off if using a webpack plugin to generate HTML such as `html-webpack-plugin`
|
||||||
|
|
||||||
### index
|
### index
|
||||||
|
|
||||||
Type: `string`
|
Type: `string`
|
||||||
|
|||||||
@ -103,6 +103,14 @@ Type: `string`
|
|||||||
|
|
||||||
The file to replace with.
|
The file to replace with.
|
||||||
|
|
||||||
|
### generateIndexHtml
|
||||||
|
|
||||||
|
Default: `true`
|
||||||
|
|
||||||
|
Type: `boolean`
|
||||||
|
|
||||||
|
Generates `index.html` file to the output path. This can be turned off if using a webpack plugin to generate HTML such as `html-webpack-plugin`
|
||||||
|
|
||||||
### index
|
### index
|
||||||
|
|
||||||
Type: `string`
|
Type: `string`
|
||||||
|
|||||||
@ -404,6 +404,8 @@ describe('index.html interpolation', () => {
|
|||||||
const distPath = `dist/apps/${appName}`;
|
const distPath = `dist/apps/${appName}`;
|
||||||
const resultIndexContents = readFile(`${distPath}/index.html`);
|
const resultIndexContents = readFile(`${distPath}/index.html`);
|
||||||
|
|
||||||
expect(resultIndexContents).toBe(expectedBuiltIndex);
|
expect(resultIndexContents).toMatch(/<div>Nx Variable: foo<\/div>/);
|
||||||
|
expect(resultIndexContents).toMatch(/<div>Nx Variable: foo<\/div>/);
|
||||||
|
expect(resultIndexContents).toMatch(/ <div>Nx Variable: foo<\/div>/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -58,6 +58,8 @@ export interface WebBuildBuilderOptions extends BuildBuilderOptions {
|
|||||||
buildLibsFromSource?: boolean;
|
buildLibsFromSource?: boolean;
|
||||||
|
|
||||||
deleteOutputPath?: boolean;
|
deleteOutputPath?: boolean;
|
||||||
|
|
||||||
|
generateIndexHtml?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWebpackConfigs(
|
function getWebpackConfigs(
|
||||||
@ -186,7 +188,7 @@ export function run(options: WebBuildBuilderOptions, context: ExecutorContext) {
|
|||||||
result1 && !result1.hasErrors() && (!result2 || !result2.hasErrors());
|
result1 && !result1.hasErrors() && (!result2 || !result2.hasErrors());
|
||||||
const emittedFiles1 = getEmittedFiles(result1);
|
const emittedFiles1 = getEmittedFiles(result1);
|
||||||
const emittedFiles2 = result2 ? getEmittedFiles(result2) : [];
|
const emittedFiles2 = result2 ? getEmittedFiles(result2) : [];
|
||||||
if (options.optimization) {
|
if (options.generateIndexHtml) {
|
||||||
await writeIndexHtml({
|
await writeIndexHtml({
|
||||||
crossOrigin: options.crossOrigin,
|
crossOrigin: options.crossOrigin,
|
||||||
outputPath: join(options.outputPath, basename(options.index)),
|
outputPath: join(options.outputPath, basename(options.index)),
|
||||||
|
|||||||
@ -253,6 +253,11 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Read buildable libraries from source instead of building them separately.",
|
"description": "Read buildable libraries from source instead of building them separately.",
|
||||||
"default": true
|
"default": true
|
||||||
|
},
|
||||||
|
"generateIndexHtml": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Generates `index.html` file to the output path. This can be turned off if using a webpack plugin to generate HTML such as `html-webpack-plugin`",
|
||||||
|
"default": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["tsConfig", "main", "index"],
|
"required": ["tsConfig", "main", "index"],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user