2016-07-02 21:05:44 +00:00
|
|
|
import gulp from 'gulp';
|
|
|
|
import path from 'path';
|
|
|
|
import webpack from 'webpack';
|
|
|
|
import WebpackDevServer from 'webpack-dev-server';
|
|
|
|
import karma from 'karma';
|
|
|
|
import ip from 'ip';
|
|
|
|
import webpackConfig from './webpack.config';
|
2016-07-07 20:21:42 +00:00
|
|
|
import del from 'del';
|
2016-07-02 21:05:44 +00:00
|
|
|
|
|
|
|
|
2016-07-07 20:32:51 +00:00
|
|
|
gulp.task('clean', function () {
|
|
|
|
return del([
|
|
|
|
'dist/*.js',
|
|
|
|
'target/build']
|
|
|
|
);
|
2016-07-07 20:21:42 +00:00
|
|
|
});
|
2016-07-02 21:05:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gulp-Task: Fuehrt webpack aus und startet den Development-Server
|
|
|
|
*/
|
|
|
|
gulp.task('dev-server', () => {
|
|
|
|
return new WebpackDevServer(webpack(webpackConfig.development), {
|
|
|
|
hot: true,
|
|
|
|
contentBase: './dist/',
|
|
|
|
watchOptions: {
|
|
|
|
aggregateTimeout: 100, poll: 300
|
|
|
|
}, stats: {
|
|
|
|
colors: true
|
|
|
|
}
|
|
|
|
}).listen(3000, 'localhost', function (err) {
|
|
|
|
if (err) {
|
|
|
|
console.error(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gulp-Task: Fuehrt die Karma-Tests auf dem PhantomJS Browser aus
|
|
|
|
*/
|
|
|
|
gulp.task('test-phantomjs', (done) => {
|
|
|
|
|
|
|
|
let hostname = process.env.host || ip.address();
|
|
|
|
let externalport = process.env.externalport || 7777;
|
|
|
|
|
|
|
|
return new karma.Server({
|
|
|
|
configFile: __dirname + '/karma.conf.js',
|
|
|
|
hostname: hostname,
|
|
|
|
port: externalport,
|
|
|
|
browsers: ['PhantomJS']
|
|
|
|
}, done).start();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('webpack-prod', [], (done) => {
|
|
|
|
return webpack(webpackConfig.production, done);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-07-07 20:32:51 +00:00
|
|
|
gulp.task('build', ['test-phantomjs', 'clean', 'webpack-prod'], (done) => {
|
2016-07-07 20:11:12 +00:00
|
|
|
return gulp
|
|
|
|
.src(path.join('target', 'build', '*'))
|
2016-07-07 20:21:42 +00:00
|
|
|
.pipe(gulp.dest('dist'));
|
2016-07-02 21:05:44 +00:00
|
|
|
});
|
|
|
|
|
2016-07-07 20:32:51 +00:00
|
|
|
gulp.task('build-skipTests', ['clean', 'webpack-prod'], (done) => {
|
2016-07-07 20:11:12 +00:00
|
|
|
return gulp
|
|
|
|
.src(path.join('target', 'build', '*'))
|
2016-07-07 20:21:42 +00:00
|
|
|
.pipe(gulp.dest('dist'));
|
2016-07-02 21:05:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('default', ['dev-server']);
|