|
1 |
| -import {task} from 'gulp'; |
| 1 | +import {task, dest} from 'gulp'; |
2 | 2 | import {tsBuildTask, copyTask, serverTask} from '../util/task_helpers';
|
3 | 3 | import {join} from 'path';
|
4 | 4 | import {
|
5 |
| - buildConfig, copyFiles, buildScssTask, sequenceTask, watchFiles |
| 5 | + buildConfig, copyFiles, buildScssPipeline, sequenceTask, watchFiles |
6 | 6 | } from 'material2-build-tools';
|
7 | 7 | import {
|
8 | 8 | cdkPackage,
|
@@ -43,53 +43,35 @@ const vendorGlob = `+(${appVendors.join('|')})/**/*.+(html|css|js|map)`;
|
43 | 43 | /** Glob that matches all assets that need to be copied to the output. */
|
44 | 44 | const assetsGlob = join(appDir, `**/*.+(html|css|svg|ico)`);
|
45 | 45 |
|
46 |
| -task(':watch:devapp', () => { |
47 |
| - watchFiles(join(appDir, '**/*.ts'), [':build:devapp:ts']); |
48 |
| - watchFiles(join(appDir, '**/*.scss'), [':build:devapp:scss']); |
49 |
| - watchFiles(join(appDir, '**/*.html'), [':build:devapp:assets']); |
50 |
| - |
51 |
| - // Custom watchers for all packages that are used inside of the demo-app. This is necessary |
52 |
| - // because we only want to build the changed package (using the build-no-bundles task). |
53 |
| - watchFiles(join(cdkPackage.sourceDir, '**/*'), ['cdk:build-no-bundles']); |
54 |
| - watchFiles(join(materialPackage.sourceDir, '**/!(*.scss)'), ['material:build-no-bundles']); |
55 |
| - watchFiles(join(materialPackage.sourceDir, '**/*.scss'), [':build:devapp:material-with-styles']); |
56 |
| - watchFiles(join(momentAdapterPackage.sourceDir, '**/*'), |
57 |
| - ['material-moment-adapter:build-no-bundles']); |
58 |
| - watchFiles(join(materialExperimentalPackage.sourceDir, '**/*'), |
59 |
| - ['material-experimental:build-no-bundles']); |
60 |
| - watchFiles(join(cdkExperimentalPackage.sourceDir, '**/*'), |
61 |
| - ['cdk-experimental:build-no-bundles']); |
62 |
| - watchFiles(join(examplesPackage.sourceDir, '**/*'), ['material-examples:build-no-bundles']); |
63 |
| -}); |
64 |
| - |
65 | 46 | /** Path to the demo-app tsconfig file. */
|
66 | 47 | const tsconfigPath = join(appDir, 'tsconfig-build.json');
|
67 | 48 |
|
68 | 49 | task(':build:devapp:ts', tsBuildTask(tsconfigPath));
|
69 |
| -task(':build:devapp:scss', buildScssTask(outDir, appDir)); |
70 | 50 | task(':build:devapp:assets', copyTask(assetsGlob, outDir));
|
| 51 | +task(':build:devapp:scss', () => buildScssPipeline(appDir).pipe(dest(outDir))); |
71 | 52 |
|
72 | 53 | task(':serve:devapp', serverTask(outDir, true));
|
73 | 54 |
|
74 |
| -// The themes for the demo-app are built by using the SCSS mixins from Material. |
75 |
| -// Therefore when SCSS files have been changed, the custom theme needs to be rebuilt. |
76 |
| -task(':build:devapp:material-with-styles', sequenceTask( |
77 |
| - 'material:build-no-bundles', ':build:devapp:scss' |
78 |
| -)); |
79 |
| - |
80 | 55 | task('build:devapp', sequenceTask(
|
81 | 56 | 'cdk:build-no-bundles',
|
82 | 57 | 'material:build-no-bundles',
|
83 | 58 | 'cdk-experimental:build-no-bundles',
|
84 | 59 | 'material-experimental:build-no-bundles',
|
85 | 60 | 'material-moment-adapter:build-no-bundles',
|
86 |
| - 'build-examples-module', // The examples module needs to be built before building examples package |
| 61 | + 'build-examples-module', |
| 62 | + // The examples module needs to be manually built before building examples package because |
| 63 | + // when using the `no-bundles` task, the package-specific pre-build tasks won't be executed. |
87 | 64 | 'material-examples:build-no-bundles',
|
88 | 65 | [':build:devapp:assets', ':build:devapp:scss', ':build:devapp:ts']
|
89 | 66 | ));
|
90 | 67 |
|
91 | 68 | task('serve:devapp', ['build:devapp'], sequenceTask([':serve:devapp', ':watch:devapp']));
|
92 | 69 |
|
| 70 | +/* |
| 71 | + * Development App deployment tasks. These can be used to run the dev-app outside of our |
| 72 | + * serve task with a middleware. e.g. on Firebase hosting. |
| 73 | + */ |
| 74 | + |
93 | 75 | /** Task that copies all vendors into the demo-app package. Allows hosting the app on firebase. */
|
94 | 76 | task('stage-deploy:devapp', ['build:devapp'], () => {
|
95 | 77 | copyFiles(join(projectDir, 'node_modules'), vendorGlob, join(outDir, 'node_modules'));
|
@@ -118,3 +100,40 @@ task('deploy:devapp', ['stage-deploy:devapp'], () => {
|
118 | 100 | .then(() => { console.log('Successfully deployed the demo-app to firebase'); process.exit(0); })
|
119 | 101 | .catch((err: any) => { console.log(err); process.exit(1); });
|
120 | 102 | });
|
| 103 | + |
| 104 | +/* |
| 105 | + * Development app watch task. This task ensures that only the packages that have been affected |
| 106 | + * by a file-change are being rebuilt. This speeds-up development and makes working on Material |
| 107 | + * easier. |
| 108 | + */ |
| 109 | + |
| 110 | +task(':watch:devapp', () => { |
| 111 | + watchFiles(join(appDir, '**/*.ts'), [':build:devapp:ts']); |
| 112 | + watchFiles(join(appDir, '**/*.scss'), [':build:devapp:scss']); |
| 113 | + watchFiles(join(appDir, '**/*.html'), [':build:devapp:assets']); |
| 114 | + |
| 115 | + // Custom watchers for all packages that are used inside of the demo-app. This is necessary |
| 116 | + // because we only want to build the changed package (using the build-no-bundles task). |
| 117 | + |
| 118 | + // CDK package watchers. |
| 119 | + watchFiles(join(cdkPackage.sourceDir, '**/*'), ['cdk:build-no-bundles']); |
| 120 | + |
| 121 | + // Material package watchers. |
| 122 | + watchFiles(join(materialPackage.sourceDir, '**/!(*-theme).scss'), ['material:build-no-bundles']); |
| 123 | + watchFiles(join(materialPackage.sourceDir, '**/*-theme.scss'), [':build:devapp:scss']); |
| 124 | + |
| 125 | + // Moment adapter package watchers |
| 126 | + watchFiles(join(momentAdapterPackage.sourceDir, '**/*'), |
| 127 | + ['material-moment-adapter:build-no-bundles']); |
| 128 | + |
| 129 | + // Material experimental package watchers |
| 130 | + watchFiles(join(materialExperimentalPackage.sourceDir, '**/*'), |
| 131 | + ['material-experimental:build-no-bundles']); |
| 132 | + |
| 133 | + // CDK experimental package watchers |
| 134 | + watchFiles(join(cdkExperimentalPackage.sourceDir, '**/*'), |
| 135 | + ['cdk-experimental:build-no-bundles']); |
| 136 | + |
| 137 | + // Example package watchers. |
| 138 | + watchFiles(join(examplesPackage.sourceDir, '**/*'), ['material-examples:build-no-bundles']); |
| 139 | +}); |
0 commit comments