| Index: web/apps/gulp-common.js
|
| diff --git a/web/apps/gulp-common.js b/web/apps/gulp-common.js
|
| index 7ef93b7a05759aac4610da2a83b2a1670e89dce6..4d6d2d508d3f5b434d14a8f515693c1959ced2c5 100644
|
| --- a/web/apps/gulp-common.js
|
| +++ b/web/apps/gulp-common.js
|
| @@ -21,23 +21,16 @@
|
|
|
| // Include Gulp & tools we'll use
|
| var $ = exports.plugins;
|
| +var del = require('del');
|
| +var requireDir = require('require-dir');
|
| +var runSequence = require('run-sequence');
|
| var browserSync = require('browser-sync');
|
| -var debug = require('gulp-debug');
|
| -var del = require('del');
|
| -var foreach = require('gulp-foreach');
|
| +var reload = browserSync.reload;
|
| +var merge = require('merge-stream');
|
| var fs = require('fs');
|
| var glob = require('glob-all');
|
| var historyApiFallback = require('connect-history-api-fallback');
|
| -var hyd = require('hydrolysis');
|
| -var merge = require('merge-stream');
|
| -var pathExists = require('path-exists');
|
| -var reload = browserSync.reload;
|
| -var rename = require('gulp-rename');
|
| -var requireDir = require('require-dir');
|
| -var runSequence = require('run-sequence');
|
| -var through = require('through2');
|
| -var ts = require('gulp-typescript');
|
| -
|
| +var crypto = require('crypto');
|
|
|
| var AUTOPREFIXER_BROWSERS = [
|
| 'ie >= 10',
|
| @@ -53,7 +46,6 @@
|
|
|
| exports.setup = function(gulp, config) {
|
| var APP = path.basename(config.dir);
|
| - var BUILD = path.join('.tmp', 'build');
|
| var DIST = path.join(exports.out, 'dist', APP);
|
|
|
| var layout = {
|
| @@ -82,7 +74,7 @@
|
|
|
| var styleTask = function(stylesPath, srcs) {
|
| return gulp.src(srcs.map(function(src) {
|
| - return path.join(BUILD, stylesPath, src);
|
| + return path.join(stylesPath, src);
|
| }))
|
| .pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
|
| .pipe(gulp.dest('.tmp/' + stylesPath))
|
| @@ -92,7 +84,7 @@
|
| };
|
|
|
| var imageOptimizeTask = function(src, dest) {
|
| - return gulp.src(path.join(BUILD, src))
|
| + return gulp.src(src)
|
| .pipe($.imagemin({
|
| progressive: true,
|
| interlaced: true
|
| @@ -103,10 +95,10 @@
|
|
|
| var optimizeHtmlTask = function(src, dest) {
|
| var assets = $.useref.assets({
|
| - searchPath: ['.tmp', config.dir]
|
| + searchPath: ['.tmp', 'app']
|
| });
|
|
|
| - return gulp.src(src, {cwd: BUILD})
|
| + return gulp.src(src)
|
| .pipe(assets)
|
| // Concatenate and minify JavaScript
|
| .pipe($.if('*.js', $.uglify({
|
| @@ -130,126 +122,51 @@
|
| }));
|
| };
|
|
|
| - gulp.task('build', function() {
|
| - // Copy application directories.
|
| - var app = gulp.src([
|
| - '**',
|
| - '!inc',
|
| - ]).pipe(gulp.dest(BUILD));
|
| -
|
| - var inc = gulp.src('inc/**/*', { cwd: exports.base })
|
| - .pipe(gulp.dest(path.join(BUILD, 'inc')));
|
| - return merge(app, inc);
|
| - });
|
| -
|
| // Compile and automatically prefix stylesheets
|
| - gulp.task('styles', ['build'], function() {
|
| + gulp.task('styles', function() {
|
| return styleTask('styles', ['**/*.css']);
|
| });
|
|
|
| - gulp.task('elements', ['build'], function() {
|
| + gulp.task('elements', function() {
|
| return styleTask('elements', ['**/*.css']);
|
| });
|
|
|
| // Optimize images
|
| - gulp.task('images', ['build'], function() {
|
| + gulp.task('images', function() {
|
| return imageOptimizeTask('images/**/*', layout.dist('images'));
|
| });
|
|
|
| - // Transpiles "inc/*/*.ts" and deposits the result alongside their source
|
| - // "ts" files.
|
| - gulp.task('tsinline', function() {
|
| - // Transpile each TypeScript module independently into JavaScript in the
|
| - // BUILD directory.
|
| - var incDir = path.join(exports.base, 'inc')
|
| - var tsconfigPath = path.join(incDir, 'tsconfig.json');
|
| - var tsProj = ts.createProject(tsconfigPath, {
|
| - typeRoots: [path.join(exports.base, 'node_modules', '@types')],
|
| - });
|
| - return gulp.src('*/*.ts', { cwd: incDir })
|
| - .pipe(tsProj())
|
| - .pipe(gulp.dest(incDir));
|
| - });
|
| -
|
| - var tsCompileSingle = function(tsconfigPath, dest) {
|
| - // Transpile each TypeScript module independently into JavaScript in the
|
| - // BUILD directory.
|
| - return pathExists(tsconfigPath).then( (exists) => {
|
| - if ( !exists ) {
|
| - return;
|
| - }
|
| -
|
| - var tsProj = ts.createProject(tsconfigPath, {
|
| - target: 'ES5', // Vulcanize can't handle ES6 ATM.
|
| - removeComments: true,
|
| - module: "amd",
|
| - outFile: 'ts-app.js',
|
| - typeRoots: [path.join(exports.base, 'node_modules', '@types')],
|
| - });
|
| - return gulp.src('main.ts', { cwd: path.join(BUILD, 'scripts-ts') })
|
| - .pipe(tsProj())
|
| - .pipe(rename(function(fpath) {
|
| - fpath.dirname = ".";
|
| - }))
|
| - .pipe(gulp.dest(dest));
|
| - } );
|
| - };
|
| -
|
| - // Builds the project's "ts-app.js" into the project directory.
|
| - gulp.task('tsproject', function() {
|
| - return tsCompileSingle(
|
| - path.join(BUILD, 'scripts-ts', 'tsconfig.json'),
|
| - path.join('scripts') );
|
| - });
|
| -
|
| - gulp.task('ts', ['build'], function() {
|
| - return tsCompileSingle(
|
| - path.join(BUILD, 'scripts-ts', 'tsconfig.json'),
|
| - path.join(path.join(BUILD, 'scripts')) );
|
| - });
|
| -
|
| // Copy all files at the root level (app)
|
| - gulp.task('copy', ['build'], function() {
|
| + gulp.task('copy', function() {
|
| // Application files.
|
| var app = gulp.src([
|
| '*',
|
| '!inc',
|
| '!test',
|
| '!elements',
|
| - '!inc/bower_components',
|
| + '!bower_components',
|
| '!cache-config.json',
|
| '!**/.DS_Store',
|
| '!gulpfile.js',
|
| '!package.json',
|
| - '!scripts-ts',
|
| - ], {
|
| - cwd: BUILD,
|
| - }).pipe(gulp.dest(layout.dist()));
|
| + ]).pipe(gulp.dest(layout.dist()));
|
|
|
| // Copy over only the bower_components we need
|
| // These are things which cannot be vulcanized
|
| var webcomponentsjs = gulp.src([
|
| 'inc/bower_components/webcomponentsjs/webcomponents-lite.min.js',
|
| - ], {
|
| - cwd: BUILD,
|
| - }).pipe(gulp.dest(layout.dist('inc/bower_components/webcomponentsjs/')));
|
| -
|
| - var requirejs = gulp.src([
|
| - 'inc/bower_components/requirejs/require.js',
|
| - ], {
|
| - cwd: BUILD,
|
| - }).pipe(gulp.dest(layout.dist('inc/bower_components/requirejs/')));
|
| + ]).pipe(gulp.dest(layout.dist('inc/bower_components/webcomponentsjs/')));
|
|
|
| var includes = (config.includes) ? (config.includes(gulp, layout)) : ([]);
|
| - return merge(app, includes, webcomponentsjs, requirejs)
|
| + return merge(app, includes, webcomponentsjs)
|
| .pipe($.size({
|
| title: 'copy'
|
| }));
|
| });
|
|
|
| // Copy web fonts to dist
|
| - gulp.task('fonts', ['build'], function() {
|
| - return gulp.src(['fonts/**'], {cwd: BUILD})
|
| + gulp.task('fonts', function() {
|
| + return gulp.src(['fonts/**'])
|
| .pipe(gulp.dest(layout.dist('fonts')))
|
| .pipe($.size({
|
| title: 'fonts'
|
| @@ -257,20 +174,19 @@
|
| });
|
|
|
| // Scan your HTML for assets & optimize them
|
| - gulp.task('html', ['build'], function() {
|
| + gulp.task('html', function() {
|
| return optimizeHtmlTask(
|
| ['**/*.html', '!{elements,test,inc}/**/*.html'],
|
| layout.dist());
|
| });
|
|
|
| // Vulcanize granular configuration
|
| - gulp.task('vulcanize', ['build', 'ts'], function() {
|
| - var fsResolver = hyd.FSResolver
|
| - return gulp.src('elements/elements.html', {cwd: BUILD})
|
| + gulp.task('vulcanize', function() {
|
| + return gulp.src('elements/elements.html')
|
| .pipe($.vulcanize({
|
| stripComments: true,
|
| inlineCss: true,
|
| - inlineScripts: true,
|
| + inlineScripts: true
|
| }))
|
| .pipe(gulp.dest(layout.dist('elements')))
|
| .pipe($.size({title: 'vulcanize'}));
|
| @@ -285,20 +201,9 @@
|
| });
|
|
|
| // Watch files for changes & reload
|
| - gulp.task('servebuild', ['build'], function() {
|
| - gulp.watch([
|
| - '**',
|
| - '!.tmp',
|
| - ], ['build']);
|
| - });
|
| -
|
| - // Watch files for changes & reload
|
| - gulp.task('serve', ['default'], function() {
|
| + gulp.task('serve', ['styles', 'elements'], function() {
|
| browserSync({
|
| - port: 8000,
|
| - ui: {
|
| - port: 8080,
|
| - },
|
| + port: 5000,
|
| notify: false,
|
| logPrefix: 'PSK',
|
| snippetOptions: {
|
| @@ -314,25 +219,21 @@
|
| // will present a certificate warning in the browser.
|
| // https: true,
|
| server: {
|
| - baseDir: [BUILD],
|
| + baseDir: ['.tmp', 'app'],
|
| middleware: [historyApiFallback()]
|
| }
|
| });
|
|
|
| - gulp.watch(['**/*.html'], ['html', reload]);
|
| + gulp.watch(['**/*.html'], reload);
|
| gulp.watch(['styles/**/*.css'], ['styles', reload]);
|
| gulp.watch(['elements/**/*.css'], ['elements', reload]);
|
| - gulp.watch(['images/**/*'], ['build', reload]);
|
| - gulp.watch(['inc/**/*'], { cwd: exports.base }, ['ts', reload]);
|
| + gulp.watch(['images/**/*'], reload);
|
| });
|
|
|
| // Build and serve the output from the dist build
|
| gulp.task('serve:dist', ['default'], function() {
|
| browserSync({
|
| - port: 8000,
|
| - ui: {
|
| - port: 8080,
|
| - },
|
| + port: 5001,
|
| notify: false,
|
| logPrefix: 'PSK',
|
| snippetOptions: {
|
| @@ -355,7 +256,7 @@
|
| // Build production files, the default task
|
| gulp.task('default', ['clean'], function(cb) {
|
| runSequence(
|
| - ['ts', 'copy', 'styles', 'images', 'fonts', 'html'],
|
| + ['copy', 'styles', 'images', 'fonts', 'html'],
|
| 'vulcanize',
|
| cb);
|
| });
|
|
|