chore(e2e): update e2e watch to use gulp-connect and open

references #8411
This commit is contained in:
Brandy Carney
2016-10-11 11:16:37 -04:00
parent 17fdfa80ec
commit 3cf90c6eb8
3 changed files with 27 additions and 26 deletions

View File

@ -71,9 +71,11 @@
"gulp-autoprefixer": "3.1.1", "gulp-autoprefixer": "3.1.1",
"gulp-clean-css": "2.0.12", "gulp-clean-css": "2.0.12",
"gulp-concat": "2.6.0", "gulp-concat": "2.6.0",
"gulp-connect": "^5.0.0",
"gulp-conventional-changelog": "^1.1.0", "gulp-conventional-changelog": "^1.1.0",
"gulp-git": "1.11.3", "gulp-git": "1.11.3",
"gulp-if": "2.0.1", "gulp-if": "2.0.1",
"gulp-open": "^2.0.0",
"gulp-remember": "0.3.1", "gulp-remember": "0.3.1",
"gulp-rename": "1.2.2", "gulp-rename": "1.2.2",
"gulp-sass": "2.3.2", "gulp-sass": "2.3.2",

View File

@ -2,8 +2,11 @@ declare module 'conventional-changelog';
declare module 'dgeni'; declare module 'dgeni';
declare module 'event-stream'; declare module 'event-stream';
declare module 'github'; declare module 'github';
declare module 'gulp-connect';
declare module 'gulp-if'; declare module 'gulp-if';
declare module 'gulp-open';
declare module 'gulp-scss-lint'; declare module 'gulp-scss-lint';
declare module 'gulp-server-livereload';
declare module 'gulp-tslint'; declare module 'gulp-tslint';
declare module 'html-entities'; declare module 'html-entities';
declare module 'rollup'; declare module 'rollup';

View File

@ -3,12 +3,15 @@ import { dirname, join } from 'path';
import * as glob from 'glob'; import * as glob from 'glob';
import {dest, src, start, task} from 'gulp'; import {dest, src, start, task} from 'gulp';
import * as connect from 'gulp-connect';
import * as gulpif from 'gulp-if'; import * as gulpif from 'gulp-if';
import * as open from 'gulp-open';
import * as watch from 'gulp-watch'; import * as watch from 'gulp-watch';
import { template } from 'lodash'; import { template } from 'lodash';
import * as rollup from 'rollup'; import * as rollup from 'rollup';
import * as nodeResolve from 'rollup-plugin-node-resolve'; import * as nodeResolve from 'rollup-plugin-node-resolve';
import * as commonjs from 'rollup-plugin-commonjs'; import * as commonjs from 'rollup-plugin-commonjs';
import * as del from 'del';
import * as runSequence from 'run-sequence'; import * as runSequence from 'run-sequence';
import { obj } from 'through2'; import { obj } from 'through2';
import * as VinylFile from 'vinyl'; import * as VinylFile from 'vinyl';
@ -20,9 +23,17 @@ import { compileSass, copyFonts, createTempTsConfig, createTimestamp, deleteFile
task('e2e', e2eBuild); task('e2e', e2eBuild);
function e2eBuild(done: (err: any) => void) { function e2eBuild(done: (err: any) => void) {
runSequence('e2e.polyfill', 'e2e.copySource', 'e2e.compileTests', 'e2e.copyExternalDependencies', 'e2e.sass', 'e2e.fonts', 'e2e.bundle', done); runSequence('e2e.clean', 'e2e.polyfill', 'e2e.copySource', 'e2e.compileTests', 'e2e.copyExternalDependencies', 'e2e.sass', 'e2e.fonts', 'e2e.bundle', done);
} }
task('e2e.clean', (done: Function) => {
del(['dist/e2e/**']).then(() => {
done();
}).catch(err => {
done(err);
});
});
task('e2e.polyfill', (done: Function) => { task('e2e.polyfill', (done: Function) => {
writePolyfills('dist/e2e/polyfills').then(() => { writePolyfills('dist/e2e/polyfills').then(() => {
done(); done();
@ -254,19 +265,6 @@ task('e2e.watch', ['e2e.copyExternalDependencies', 'e2e.sass', 'e2e.fonts'], (do
}); });
function e2eWatch(componentName: string, componentTest: string) { function e2eWatch(componentName: string, componentTest: string) {
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const config = require('../../e2e/webpack.config.js');
config.output.path = join(__dirname, '../../../');
config.entry = {
'dist/e2e/vendor': './scripts/e2e/vendor',
'dist-e2e/polyfills': './scripts/e2e/polyfills'
};
config.entry[`./dist/e2e/components/${componentName}/test/${componentTest}/index`] = `./dist/e2e/components/${componentName}/test/${componentTest}/entry`;
const compiler = webpack(config);
// If any tests change within components then run e2e.resources. // If any tests change within components then run e2e.resources.
watch([ watch([
'src/components/*/test/**/*' 'src/components/*/test/**/*'
@ -293,19 +291,17 @@ function e2eWatch(componentName: string, componentTest: string) {
start('e2e.sass'); start('e2e.sass');
}); });
new WebpackDevServer(compiler, {
noInfo: true,
quiet: false,
watchOptions: {
aggregateTimeout: 2000,
poll: 1000
}
}).listen(LOCAL_SERVER_PORT, 'localhost', function(err) {
if (err) {
throw err;
}
console.log(`http://localhost:${LOCAL_SERVER_PORT}/${DIST_NAME}/${E2E_NAME}/components/${componentName}/test/${componentTest}/`); console.log(`http://localhost:${LOCAL_SERVER_PORT}/${DIST_NAME}/${E2E_NAME}/components/${componentName}/test/${componentTest}/`);
connect.server({
root: './',
port: LOCAL_SERVER_PORT,
livereload: true
}); });
src('dist').pipe(
open({uri: `http://localhost:${LOCAL_SERVER_PORT}/${DIST_NAME}/${E2E_NAME}`})
);
} }
function e2eComponentsExists(): boolean { function e2eComponentsExists(): boolean {