Skip to content

Commit 3bd03b2

Browse files
authored
Merge pull request #54 from bikecoders/set-automatically-production-when-ng-add
feat: add production build target on ng-add if exists
2 parents 1c63edb + 3959732 commit 3bd03b2

File tree

6 files changed

+807
-1388
lines changed

6 files changed

+807
-1388
lines changed

package-lock.json

Lines changed: 0 additions & 335 deletions
This file was deleted.

src/interfaces.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ export interface WorkspaceProject {
22
projectType?: string;
33
architect?: Record<
44
string,
5-
{ builder: string; options?: Record<string, any> }
5+
{
6+
builder: string;
7+
options?: Record<string, any>;
8+
configurations?: Record<string, Record<string, any>>;
9+
}
610
>;
711
}
812

src/ng-add.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,26 @@ describe('ng-add', () => {
120120

121121
expect(workspaceJsonModified).toEqual(expectedWorkspaceDefinition);
122122
});
123+
124+
it('should set production on the libraries that can be compiled to production', () => {
125+
const productionConfig = {
126+
production: {
127+
someConfig: true,
128+
},
129+
};
130+
originalWorkspaceDefinition.projects.publishable.architect!.build.configurations = productionConfig;
131+
expectedWorkspaceDefinition.projects.publishable.architect!.build.configurations = productionConfig;
132+
expectedWorkspaceDefinition.projects.publishable.architect!.deploy.options!.configuration =
133+
'production';
134+
tree.create('angular.json', JSON.stringify(originalWorkspaceDefinition));
135+
136+
const result = ngAdd()(tree, {} as SchematicContext);
137+
const workspaceJsonModified = JSON.parse(
138+
result.read('angular.json')!.toString()
139+
);
140+
141+
expect(workspaceJsonModified).toEqual(expectedWorkspaceDefinition);
142+
});
123143
});
124144

125145
describe('error handling', () => {

0 commit comments

Comments
 (0)