Skip to content

chore(dev-app): prevent multiple reloads per file change #1762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tools/gulp/task_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,15 @@ export function vendorTask() {
}));
}

export type livereloadOptions = boolean | {
enable: boolean;
filter: (filename: string, callback: (isAllowed: boolean) => void) => void;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semicolon.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you referring to the comma after enable or adding a semicolon after the export? If it's the latter, none of the other exports use a semicolon.


/** Create a task that serves the dist folder. */
export function serverTask(liveReload = true,
export function serverTask(liveReload: livereloadOptions = true,
streamCallback: (stream: NodeJS.ReadWriteStream) => void = null) {

return () => {
const stream = gulp.src('dist').pipe(gulpServer({
livereload: liveReload,
Expand Down
14 changes: 12 additions & 2 deletions tools/gulp/tasks/development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import {

const appDir = path.join(SOURCE_ROOT, 'demo-app');
const outDir = DIST_ROOT;

const LIVERELOAD_PATTERNS = [
/material\.umd\.js$/,
/-demo\.[a-z]+$/,
/\/theming\/prebuilt/
];

task(':watch:devapp', () => {
watch(path.join(appDir, '**/*.ts'), [':build:devapp:ts']);
Expand All @@ -25,7 +29,13 @@ task(':build:devapp:scss', [':build:components:scss'], sassBuildTask(outDir, app
task(':build:devapp:assets', copyTask(appDir, outDir));
task('build:devapp', buildAppTask('devapp'));

task(':serve:devapp', serverTask());
task(':serve:devapp', serverTask({
enable: true,
filter: (filename: string, callback: Function) => {
callback(LIVERELOAD_PATTERNS.some(pattern => pattern.test(filename)));
}
}));

task('serve:devapp', ['build:devapp'], sequenceTask(
[':serve:devapp', ':watch:components', ':watch:devapp']
));