fix(web): handle delete-output-path option

Closes #4015
This commit is contained in:
Tasos Bekos 2021-01-07 12:52:16 +02:00 committed by Victor Savkin
parent 2a47cdf0aa
commit f95f855cf7
12 changed files with 76 additions and 2 deletions

View File

@ -48,6 +48,14 @@ Type: `string`
The crossorigin attribute to use for generated javascript script tags. One of 'none' | 'anonymous' | 'use-credentials'
### deleteOutputPath
Default: `true`
Type: `boolean`
Delete the output path before building.
### deployUrl
Type: `string`

View File

@ -28,6 +28,14 @@ Possible values: `dependencies`, `peerDependencies`
When updateBuildableProjectDepsInPackageJson is true, this adds dependencies to either `peerDependencies` or `dependencies`
### deleteOutputPath
Default: `true`
Type: `boolean`
Delete the output path before building.
### entryFile
Type: `string`

View File

@ -49,6 +49,14 @@ Type: `string`
The crossorigin attribute to use for generated javascript script tags. One of 'none' | 'anonymous' | 'use-credentials'
### deleteOutputPath
Default: `true`
Type: `boolean`
Delete the output path before building.
### deployUrl
Type: `string`

View File

@ -29,6 +29,14 @@ Possible values: `dependencies`, `peerDependencies`
When updateBuildableProjectDepsInPackageJson is true, this adds dependencies to either `peerDependencies` or `dependencies`
### deleteOutputPath
Default: `true`
Type: `boolean`
Delete the output path before building.
### entryFile
Type: `string`

View File

@ -49,6 +49,14 @@ Type: `string`
The crossorigin attribute to use for generated javascript script tags. One of 'none' | 'anonymous' | 'use-credentials'
### deleteOutputPath
Default: `true`
Type: `boolean`
Delete the output path before building.
### deployUrl
Type: `string`

View File

@ -29,6 +29,14 @@ Possible values: `dependencies`, `peerDependencies`
When updateBuildableProjectDepsInPackageJson is true, this adds dependencies to either `peerDependencies` or `dependencies`
### deleteOutputPath
Default: `true`
Type: `boolean`
Delete the output path before building.
### entryFile
Type: `string`

View File

@ -74,6 +74,15 @@ describe('Web Components Applications', () => {
`dist/libs/${libName}/_should_remove.txt`
);
checkFilesExist(`dist/apps/_should_not_remove.txt`);
// `delete-output-path`
createFile(`dist/apps/${appName}/_should_keep.txt`);
runCLI(`build ${appName} --delete-output-path=false`);
checkFilesExist(`dist/apps/${appName}/_should_keep.txt`);
createFile(`dist/libs/${libName}/_should_keep.txt`);
runCLI(`build ${libName} --delete-output-path=false`);
checkFilesExist(`dist/libs/${libName}/_should_keep.txt`);
}, 120000);
it('should do another build if differential loading is needed', async () => {

View File

@ -56,6 +56,8 @@ export interface WebBuildBuilderOptions extends BuildBuilderOptions {
verbose?: boolean;
buildLibsFromSource?: boolean;
deleteOutputPath?: boolean;
}
export default createBuilder<WebBuildBuilderOptions & JsonObject>(run);
@ -98,7 +100,9 @@ export function run(options: WebBuildBuilderOptions, context: BuilderContext) {
}
// Delete output path before bundling
deleteOutputDir(context.workspaceRoot, options.outputPath);
if (options.deleteOutputPath) {
deleteOutputDir(context.workspaceRoot, options.outputPath);
}
return from(getSourceRoot(context))
.pipe(

View File

@ -19,6 +19,11 @@
"type": "string",
"description": "The output path of the generated files."
},
"deleteOutputPath": {
"type": "boolean",
"description": "Delete the output path before building.",
"default": true
},
"watch": {
"type": "boolean",
"description": "Enable re-building when files change.",

View File

@ -124,7 +124,9 @@ export function run(
context.logger.info(`Bundling ${context.target.project}...`);
// Delete output path before bundling
deleteOutputDir(context.workspaceRoot, options.outputPath);
if (options.deleteOutputPath) {
deleteOutputDir(context.workspaceRoot, options.outputPath);
}
return from(rollupOptions).pipe(
concatMap((opts) =>

View File

@ -15,6 +15,11 @@
"type": "string",
"description": "The output path of the generated files."
},
"deleteOutputPath": {
"type": "boolean",
"description": "Delete the output path before building.",
"default": true
},
"tsConfig": {
"type": "string",
"description": "The path to tsconfig file."

View File

@ -60,6 +60,7 @@ export interface PackageBuilderOptions {
updateBuildableProjectDepsInPackageJson?: boolean;
buildableProjectDepsInPackageJsonType?: 'dependencies' | 'peerDependencies';
umdName?: string;
deleteOutputPath?: boolean;
}
export interface AssetGlobPattern extends JsonObject {