2015-10-17 14:12:04 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var gulp = require('gulp');
|
2015-10-24 17:04:07 +02:00
|
|
|
var $ = require('gulp-load-plugins')({
|
|
|
|
pattern: ['gulp-*', 'del', 'merge2'],
|
|
|
|
rename: {
|
|
|
|
'merge2': 'merge'
|
|
|
|
}
|
|
|
|
});
|
2015-09-26 14:02:03 +02:00
|
|
|
var browserSync = require('browser-sync').create();
|
2015-10-24 17:04:07 +02:00
|
|
|
var tsProject = $.typescript.createProject('tsconfig.json', {
|
2015-10-24 00:39:49 +02:00
|
|
|
sortOutput : true
|
|
|
|
});
|
2015-10-17 14:12:04 +02:00
|
|
|
|
2015-10-21 22:05:49 +02:00
|
|
|
gulp.task('scripts', function() {
|
2015-11-14 13:35:48 +01:00
|
|
|
var tsResult = gulp.src('src/*.ts')
|
2015-10-24 17:04:07 +02:00
|
|
|
.pipe($.sourcemaps.init())
|
|
|
|
.pipe($.typescript(tsProject));
|
2015-10-17 14:12:04 +02:00
|
|
|
|
2015-10-21 22:05:49 +02:00
|
|
|
return tsResult.js
|
2015-11-14 13:35:48 +01:00
|
|
|
.pipe($.concat('bundle.js'))
|
2015-10-24 17:04:07 +02:00
|
|
|
.pipe($.ngAnnotate())
|
|
|
|
.pipe($.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
2015-10-24 14:57:34 +02:00
|
|
|
.pipe(gulp.dest('tmp'));
|
2015-10-21 22:05:49 +02:00
|
|
|
});
|
2015-10-17 14:12:04 +02:00
|
|
|
|
2015-10-24 14:57:34 +02:00
|
|
|
// build project for serving up locally
|
|
|
|
gulp.task('tmp', ['scripts', 'dist-node-modules'], function () {
|
2015-10-18 20:05:30 +02:00
|
|
|
return gulp.src([
|
|
|
|
'src/**/*.html',
|
|
|
|
'src/**/*.css',
|
2015-11-14 19:38:34 +01:00
|
|
|
'src/load-menu-for-web-testing.js'
|
2015-10-18 20:05:30 +02:00
|
|
|
], {base: 'src'})
|
2015-10-24 17:04:07 +02:00
|
|
|
.pipe($.flatten())
|
|
|
|
.pipe($.fileInclude({
|
2015-10-24 14:57:34 +02:00
|
|
|
prefix: '@@',
|
|
|
|
basePath: '@file'
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest('tmp'));
|
|
|
|
});
|
|
|
|
|
|
|
|
// build project for loading up in Chrome
|
|
|
|
gulp.task('dist', ['tmp'], function () {
|
|
|
|
var tmp = gulp.src([
|
|
|
|
'tmp/**/*',
|
|
|
|
'!tmp/index.html',
|
2015-11-14 19:38:34 +01:00
|
|
|
'!tmp/load-menu-for-web-testing.js'
|
2015-10-24 14:57:34 +02:00
|
|
|
], {base: 'tmp'});
|
2015-10-24 23:32:12 +02:00
|
|
|
var imageAssets = gulp.src('src/plugin-specific/*.png').pipe($.flatten());
|
2015-10-24 14:57:34 +02:00
|
|
|
var chromePluginResources = gulp.src([
|
2015-10-24 23:32:12 +02:00
|
|
|
'src/plugin-specific/**/*',
|
2015-10-24 23:35:41 +02:00
|
|
|
'!src/plugin-specific/*.png',
|
2015-10-24 14:57:34 +02:00
|
|
|
])
|
2015-10-24 17:04:07 +02:00
|
|
|
.pipe($.flatten())
|
|
|
|
.pipe($.fileInclude({
|
|
|
|
prefix: '@@',
|
|
|
|
basePath: '@file'
|
2015-10-24 14:57:34 +02:00
|
|
|
}));
|
|
|
|
|
2015-10-24 20:33:16 +02:00
|
|
|
return $.merge([tmp, chromePluginResources, imageAssets])
|
2015-10-21 22:05:49 +02:00
|
|
|
.pipe(gulp.dest('dist'));
|
2015-10-18 20:05:30 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('dist-node-modules', function () {
|
|
|
|
return gulp.src([
|
2015-10-21 22:05:49 +02:00
|
|
|
'node_modules/bootstrap/**/*',
|
|
|
|
'node_modules/angular/**/*',
|
2015-10-25 21:11:23 +01:00
|
|
|
'node_modules/jquery/**/*',
|
2015-11-14 13:35:48 +01:00
|
|
|
'node_modules/lodash/**/*'
|
2015-10-18 20:05:30 +02:00
|
|
|
], {base: 'node_modules'})
|
2015-10-24 14:57:34 +02:00
|
|
|
.pipe(gulp.dest('tmp/vendor'));
|
2015-10-18 20:05:30 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('clean', function () {
|
2015-10-24 17:04:07 +02:00
|
|
|
return $.del(['tmp', 'dist']);
|
2015-10-18 20:05:30 +02:00
|
|
|
});
|
|
|
|
|
2015-10-24 20:33:16 +02:00
|
|
|
gulp.task('watch-plugin', ['dist'], function () {
|
|
|
|
gulp.watch("src/**/*", ['dist']);
|
|
|
|
});
|
|
|
|
|
2015-10-24 14:57:34 +02:00
|
|
|
gulp.task('serve', ['tmp'], function () {
|
|
|
|
// Serve files from the root of this project
|
|
|
|
browserSync.init({
|
|
|
|
server: {
|
|
|
|
baseDir: "./tmp",
|
|
|
|
}
|
|
|
|
});
|
2015-09-26 14:02:03 +02:00
|
|
|
|
2015-10-24 14:57:34 +02:00
|
|
|
// add browserSync.reload to the tasks array to make
|
|
|
|
// all browsers reload after tasks are complete.
|
2015-11-14 13:35:48 +01:00
|
|
|
gulp.watch("src/**/*.ts", ['scripts']);
|
2015-10-24 14:57:34 +02:00
|
|
|
gulp.watch([
|
|
|
|
"src/**/*.html",
|
|
|
|
"src/**/*.css",
|
|
|
|
"src/**/*.js"
|
2015-11-14 13:35:48 +01:00
|
|
|
], ['tmp']);
|
|
|
|
gulp.watch("tmp/**/*").on("change", browserSync.reload);
|
2015-09-26 14:02:03 +02:00
|
|
|
});
|