Skip to content

Commit c17cad5

Browse files
cliffkohdzearing
authored andcommitted
Make web-library-build export the tasks it defines. (microsoft#17)
* Make web-library-build export the tasks it defines. * Address CR feedback * Address CR feedback * Fix build break * More CR feedback
1 parent 3daf8f4 commit c17cad5

3 files changed

Lines changed: 40 additions & 11 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "Make web-library-build export the tasks it defines",
5+
"packageName": "@microsoft/web-library-build",
6+
"type": "minor"
7+
},
8+
{
9+
"comment": "Add documentation to CopyTask",
10+
"packageName": "@microsoft/gulp-core-build",
11+
"type": "none"
12+
}
13+
],
14+
"email": "zihankoh@microsoft.com"
15+
}

‎gulp-core-build/src/tasks/CopyTask.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,22 @@ import { GulpTask } from './GulpTask';
22
import gulp = require('gulp');
33

44
export interface ICopyConfig {
5+
/**
6+
* Object of dest: [source] for the copy task.
7+
*/
58
copyTo: {
69
[destPath: string]: string[];
710
};
11+
12+
/**
13+
* Whether to remove or replace relative path for files. True by default.
14+
*/
815
shouldFlatten?: boolean;
916
}
1017

18+
/**
19+
* This task takes in a map of dest: [sources], and copies items from one place to another.
20+
*/
1121
export class CopyTask extends GulpTask<ICopyConfig> {
1222
public taskConfig: ICopyConfig = {
1323
copyTo: {},

‎web-library-build/src/index.ts‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export * from '@microsoft/gulp-core-build-karma';
2222
export * from '@microsoft/gulp-core-build-webpack';
2323
export * from '@microsoft/gulp-core-build-serve';
2424

25+
// pre copy and post copy allows you to specify a map of dest: [sources] to copy from one place to another.
2526
export const preCopy: CopyTask = new CopyTask();
2627
preCopy.name = 'pre-copy';
2728

@@ -34,30 +35,33 @@ const sourceMatch: string[] = [
3435
];
3536

3637
// Define default task groups.
37-
let buildTasks: IExecutable = task('build', serial(preCopy, sass, parallel(tslint, typescript, text), postCopy));
38-
let bundleTasks: IExecutable = task('bundle', serial(buildTasks, webpack));
39-
const postProcessSourceMaps: PostProcessSourceMaps = new PostProcessSourceMaps();
40-
const validateShrinkwrapTask: ValidateShrinkwrapTask = new ValidateShrinkwrapTask();
41-
const generateShrinkwrapTask: GenerateShrinkwrapTask = new GenerateShrinkwrapTask();
38+
export const compileTsTasks: IExecutable = parallel(typescript, text);
39+
export const buildTasks: IExecutable = task('build', serial(preCopy, sass, parallel(compileTsTasks, text), postCopy));
40+
export const bundleTasks: IExecutable = task('bundle', serial(buildTasks, webpack));
41+
export const testTasks: IExecutable = serial(sass, compileTsTasks, karma);
42+
export const defaultTasks: IExecutable = serial(bundleTasks, karma);
43+
export const postProcessSourceMapsTask: PostProcessSourceMaps = new PostProcessSourceMaps();
44+
export const validateShrinkwrapTask: ValidateShrinkwrapTask = new ValidateShrinkwrapTask();
45+
export const generateShrinkwrapTask: GenerateShrinkwrapTask = new GenerateShrinkwrapTask();
4246

4347
task('validate-shrinkwrap', validateShrinkwrapTask);
4448
task('generate', generateShrinkwrapTask);
4549

46-
task('test', serial(sass, parallel(typescript, text), karma));
50+
task('test', serial(sass, testTasks));
4751

48-
task('test-watch', watch(sourceMatch, serial(sass, parallel(typescript, text), karma)));
52+
task('test-watch', watch(sourceMatch, serial(sass, compileTsTasks, karma)));
4953

5054
// For watch scenarios like serve, make sure to exclude generated files from src (like *.scss.ts.)
5155
task('serve',
5256
serial(
5357
bundleTasks,
5458
serve,
55-
postProcessSourceMaps as any, // tslint:disable-line:no-any
59+
postProcessSourceMapsTask,
5660
watch(
57-
sourceMatch, serial(preCopy, sass, parallel(typescript, text),
58-
postCopy, webpack, postProcessSourceMaps as any, reload) // tslint:disable-line:no-any
61+
sourceMatch, serial(preCopy, sass, compileTsTasks,
62+
postCopy, webpack, postProcessSourceMapsTask, reload)
5963
)
6064
)
6165
);
6266

63-
task('default', serial(bundleTasks, karma));
67+
task('default', defaultTasks);

0 commit comments

Comments
 (0)