100 lines
No EOL
2.4 KiB
JavaScript
100 lines
No EOL
2.4 KiB
JavaScript
'use strict';
|
|
|
|
var gulp = require('gulp');
|
|
var $ = require('gulp-load-plugins')({
|
|
pattern: ['gulp-*', 'del', 'merge2'],
|
|
rename: {
|
|
'merge2': 'merge'
|
|
}
|
|
});
|
|
var browserSync = require('browser-sync').create();
|
|
var tsProject = $.typescript.createProject('tsconfig.json', {
|
|
sortOutput : true
|
|
});
|
|
|
|
gulp.task('scripts', function() {
|
|
var tsResult = gulp.src('src/*.ts')
|
|
.pipe($.sourcemaps.init())
|
|
.pipe($.typescript(tsProject));
|
|
|
|
return tsResult.js
|
|
.pipe($.concat('bundle.js'))
|
|
.pipe($.ngAnnotate())
|
|
.pipe($.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
|
.pipe(gulp.dest('tmp'));
|
|
});
|
|
|
|
// build project for serving up locally
|
|
gulp.task('tmp', ['scripts', 'dist-node-modules'], function () {
|
|
return gulp.src([
|
|
'src/**/*.html',
|
|
'src/**/*.css',
|
|
'src/load-menu-for-web-testing.js'
|
|
], {base: 'src'})
|
|
.pipe($.flatten())
|
|
.pipe($.fileInclude({
|
|
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',
|
|
'!tmp/load-menu-for-web-testing.js'
|
|
], {base: 'tmp'});
|
|
var imageAssets = gulp.src('src/plugin-specific/*.png').pipe($.flatten());
|
|
var chromePluginResources = gulp.src([
|
|
'src/plugin-specific/**/*',
|
|
'!src/plugin-specific/*.png',
|
|
])
|
|
.pipe($.flatten())
|
|
.pipe($.fileInclude({
|
|
prefix: '@@',
|
|
basePath: '@file'
|
|
}));
|
|
|
|
return $.merge([tmp, chromePluginResources, imageAssets])
|
|
.pipe(gulp.dest('dist'));
|
|
});
|
|
|
|
gulp.task('dist-node-modules', function () {
|
|
return gulp.src([
|
|
'node_modules/bootstrap/**/*',
|
|
'node_modules/angular/**/*',
|
|
'node_modules/jquery/**/*',
|
|
'node_modules/lodash/**/*',
|
|
'node_modules/ngstorage/**/*'
|
|
], {base: 'node_modules'})
|
|
.pipe(gulp.dest('tmp/vendor'));
|
|
});
|
|
|
|
gulp.task('clean', function () {
|
|
return $.del(['tmp', 'dist']);
|
|
});
|
|
|
|
gulp.task('watch-plugin', ['dist'], function () {
|
|
gulp.watch("src/**/*", ['dist']);
|
|
});
|
|
|
|
gulp.task('serve', ['tmp'], function () {
|
|
// Serve files from the root of this project
|
|
browserSync.init({
|
|
server: {
|
|
baseDir: "./tmp",
|
|
}
|
|
});
|
|
|
|
// add browserSync.reload to the tasks array to make
|
|
// all browsers reload after tasks are complete.
|
|
gulp.watch("src/**/*.ts", ['scripts']);
|
|
gulp.watch([
|
|
"src/**/*.html",
|
|
"src/**/*.css",
|
|
"src/**/*.js"
|
|
], ['tmp']);
|
|
gulp.watch("tmp/**/*").on("change", browserSync.reload);
|
|
}); |