module.exports.createScriptTasks = function () { gulp.task("js-compile", folders(config.getSrcPath(config.path.components), function (folder) { utils.log("Compiling components js...") return gulp.src(config.getSrcPath(config.path.components, folder, '/js/*.js')) .pipe(concat(folder + '.js')) .pipe(gulp.dest(config.getDistPath(config.path.components, folder))); })); gulp.task('watch-js', function () { gulp.watch(config.getSrcPath(config.path.components, '/**/*.js'), ["js-compile"]); }); };
import folders from 'gulp-folders'; import cssToJs from 'gulp-css-to-js'; import rename from 'gulp-rename'; import strip from 'gulp-strip-css-comments'; setEnvironment(); var sass_settings = { sourceComments: development(), outputStyle: production() ? 'compressed' : 'nested', includePaths: config.styles.sassIncludePaths }; gulp.task('generate:ModuleStyles', folders(config.modules.src, function(module){ const createSourcemap = development() || config.styles.prodSourcemap; return gulp.src( config.modules.src + module + '/*.scss*' ) .pipe( gulpif(createSourcemap, sourcemaps.init()) ) .pipe( sass(sass_settings) ) .on('error', handleErrors) .pipe( autoprefixer(config.styles.autoprefixer) ) .pipe( gulpif( createSourcemap, sourcemaps.write( production() ? './' : null )) ) .pipe( production(csso()) ) .pipe( production(strip( { 'preserve' : false })) ) .pipe( cssToJs() ) .pipe( rename(module + '_css.js') ) .pipe( gulp.dest(config.modules.src + module) ) .pipe( browserSync.stream() ); }));
gulp.task('demoOneWordDescriptionClean', function () { return gulp.src('demo/components.js', {read: false}) .pipe(clean()); }) gulp.task('demoBuild', folders(componentsPath, function(component){ //This will loop over all folders inside pathToFolder main, secondary //Return stream so gulp-folders can concatenate all of them //so you still can use safely use gulp multitasking var componentDocsPath = path.join(componentsPath, component, 'docs'); var apiMd = readSync(path.join(componentDocsPath, 'readme.md')); var apiHtml = md(apiMd); var demoHtml = readSync(path.join(componentDocsPath, 'demo.html')); var codeHtml = demoHtml && htmlencode(demoHtml); var jsHtml = readSync(path.join(componentDocsPath, 'demo.js')); var cssHtml = readSync(path.join(componentDocsPath, 'demo.css')); return gulp.src('misc/demo/demoAll.tpl.html') .pipe(replace(/\{\{DEMO\}\}/g, demoHtml || 'no demo')) .pipe(replace(/\{\{API\}\}/g, apiHtml || '<!-- no apiHtml -->')) .pipe(replace(/\{\{codeHtml\}\}/g, codeHtml || '<!-- no demo html -->')) .pipe(replace(/\{\{codeJs\}\}/g, jsHtml || '// no demo js')) .pipe(replace(/\{\{codeCss\}\}/g, cssHtml || '/* no css */')) .pipe(rename('demo.tpl.html')) .pipe(gulp.dest(path.join('demo/app/components', component, 'docs'))); })); function readSync(file) { if (fs.existsSync(file)) { return fs.readFileSync(file, 'utf8'); }
(function () { "use strict"; var gulp = require("gulp"); var bump = require("gulp-bump"); var concat = require("gulp-concat"); var folders = require("gulp-folders"); var html2js = require("gulp-html2js"); var jshint = require("gulp-jshint"); var gutil = require("gulp-util"); var rename = require("gulp-rename"); var uglify = require("gulp-uglify"); var path = require("path"); var runSequence = require("run-sequence"); var factory = require("widget-tester").gulpTaskFactory; var del = require("del"); var colors = require("colors"); var minifyCSS = require("gulp-minify-css"); var bower = require("gulp-bower"); var wct = require("web-component-tester").gulp.init(gulp); gulp.task("clean", function (cb) { del(["./dist/**"], cb); }); gulp.task("clean-bower", function(cb){ del(["./components/**"], cb); }); gulp.task("config", function() { var env = process.env.NODE_ENV || "prod"; gutil.log("Environment is", env); return gulp.src(["./src/config/" + env + ".js"]) .pipe(rename("config.js")) .pipe(gulp.dest("./src/config")) .pipe(gulp.dest("dist")); }); gulp.task("bump", function(){ return gulp.src(["./package.json", "./bower.json"]) .pipe(bump({type:"patch"})) .pipe(gulp.dest("./")); }); gulp.task("lint", function() { return gulp.src("src/**/*.js") .pipe(jshint()) .pipe(jshint.reporter("jshint-stylish")) .pipe(jshint.reporter("fail")); }); gulp.task("css", function() { return gulp.src("src/css/**/*.css") .pipe(gulp.dest("dist/css")) }); gulp.task("css-concat", ["css"], function () { return gulp.src("dist/**/*.css") .pipe(concat("all.css")) .pipe(gulp.dest("dist/css")); }); gulp.task("css-minify", ["css-concat"], function () { gulp.src("dist/css/*.css") .pipe(minifyCSS()) .pipe(rename(function (path) { path.basename += ".min"; })) .pipe(gulp.dest("dist/css")); }); gulp.task("js", function (cb) { return gulp.src("src/js/*.js") .pipe(gulp.dest("dist")); }); gulp.task("js-folder", folders("src/js", function(folder) { return gulp.src(path.join("src/js", folder, "*.js")) .pipe(concat(folder + ".js")) .pipe(gulp.dest("dist")); })); gulp.task("js-concat", ["js", "js-folder"], function (cb) { return gulp.src("dist/**/*.js") .pipe(concat("all.js")) .pipe(gulp.dest("dist")); }); gulp.task("js-uglify", ["js-concat"], function () { gulp.src("dist/*.js") .pipe(uglify()) .pipe(rename(function (path) { path.basename += ".min"; })) .pipe(gulp.dest("dist")); }); gulp.task("assets", function () { gulp.src("src/assets/**/*") .pipe(gulp.dest("dist/assets")) }); // ***** e2e Testing ***** // gulp.task("e2e:server-close", factory.testServerClose()); gulp.task("e2e:server", ["config"], factory.testServer()); gulp.task("e2e:run", factory.testE2E()); gulp.task("test:e2e", function(cb) { runSequence(["e2e:server"], "e2e:run", "e2e:server-close", cb); }); // ****** Unit Testing ***** // gulp.task("test:unit", factory.testUnitAngular( {testFiles: [ "components/jquery/dist/jquery.min.js", "test/date.js", "test/data/financial.js", "node_modules/widget-tester/mocks/gadget-mocks.js", "node_modules/widget-tester/mocks/visualization-api-mock.js", "test/mocks/ajax.js", "src/config/test.js", "src/js/store-auth.js", "src/js/visualization.js", "src/js/financial/*.js", "src/js/background.js", "src/js/common.js", "src/js/rise-cache.js", "src/js/logger.js", "test/unit/**/*spec.js"]} )); // ***** Integration Testing ***** // gulp.task("test:integration", function(cb) { runSequence("test:local", cb); }); // ***** Primary Tasks ***** // gulp.task("bower-clean-install", ["clean-bower"], function(cb){ return bower().on("error", function(err) { console.log(err); cb(); }); }); gulp.task("build", function (cb) { runSequence(["clean"], ["config"], ["lint", "js-uglify", "css-minify", "assets"], cb); }); gulp.task("test", function(cb) { runSequence("test:unit", "test:e2e", "test:integration", cb) }); gulp.task("default", [], function() { console.log("********************************************************************".yellow); console.log(" gulp bower-clean-install: delete and re-install bower components".yellow); console.log(" gulp test: run e2e and unit tests".yellow); console.log(" gulp build: build a distribution version".yellow); console.log("********************************************************************".yellow); return true; }); })();
/** * Compiles and moves files from src to dist on save */ var gulp = require('gulp'), folders = require('gulp-folders'), ts = require('gulp-typescript'), tsProjects = {}, options = { target: 'es6', noImplicitAny: true, removeComments: true, declarationFiles: false, sortOutput: true, suppressImplicitAnyIndexErrors: true }; gulp.task('build', folders( 'src', function (folder) { if (!tsProjects[folder]) { tsProjects[folder] = ts.createProject(options); } return gulp.src([ 'src/**/*.ts' ]) .pipe(ts(tsProjects[folder])).js .pipe(gulp.dest('dist')); }));
var gulp = require('gulp'), path = require('path'), postcss = require('gulp-postcss'), autoprefixer = require('autoprefixer'), jsonlint = require('gulp-jsonlint'), print = require('gulp-print'), folders = require('gulp-folders'); var site = '/site/'; gulp.task('css', folders(site, function(folder) { var processors = [ autoprefixer({ browsers: ['last 2 versions', '> 5%'] }) ]; return gulp.src(path.join(site, folder, 'assets', 'css', '*.css')) .pipe(print()) .pipe(postcss(processors)) .pipe(gulp.dest('')) })); gulp.task('jsonlint', function() { gulp.src('./*.json') .pipe(print()) .pipe(jsonlint()) .pipe(jsonlint.failAfterError()) }); gulp.task('post-process', ['css']) gulp.task('lint', ['jsonlint'])
var gulp = require("gulp"), path = require("path"), folder = require("gulp-folders"), gulpIf = require("gulp-if"), concat = require("gulp-concat"), notify = require("gulp-notify"), rename = require("gulp-rename"), uglifyes = require("uglify-es"), composer = require("gulp-uglify/composer"), minify = composer(uglifyes, console), //handleErrors = require("handleErrors"), source_folder = "_javascript", destination_folder = "j", public_folder = "_site/j", rename_serviceworker = rename({ dirname: "../" }); gulp.task("scripts", folder(source_folder, function(the_folder){ return gulp.src(path.join(source_folder, the_folder, "*.js")) .pipe(concat(the_folder + ".js")) .pipe(gulpIf(the_folder=="serviceworker",rename_serviceworker)) .pipe(gulp.dest(destination_folder)) .pipe(gulp.dest(public_folder)) .pipe(rename({suffix: ".min"})) .pipe(minify()) .pipe(gulp.dest(destination_folder)) .pipe(gulp.dest(public_folder)) .pipe(notify({ message: "Scripts task complete" })); //.on("error", handleErrors); }));
entries: ['./app/main.js'], fullpaths: false, debug: true, }; var opts = assign({}, watchify.args, customOpts); var b = watchify(browserify(opts).transform(babelify)); gulp.task('clean', function (cb) { rimraf('./dist', function(){}); }); //Autobootstrap gulp.task('modules', folders('./app/modules', function(folder){ return gulp .src('./app/modules/'+folder+'/**/*.js') .pipe(ngAutoBootstrap(ngconfig)) .pipe(gulp.dest('./app/modules/'+folder)); })); gulp.task('watch', function() { gulp.watch('app/**/*.js', ['browserify']); gulp.watch('app/**/*.html', ['views'] ); gulp.watch("dist/*.html").on('change', reload); }); gulp.task('views', function() { return gulp.src('app/**/*.html') .pipe(gulp.dest('dist/')); }); gulp.task('jshint', function() {
}); function rebundle() { const stream = bundler.bundle(); const sourceMapLocation = prod ? './' : ''; return stream.on('error', handleErrors) .pipe( source(file) ) .pipe( gulpif(createSourcemap(), buffer()) ) .pipe( gulpif(createSourcemap(), sourcemaps.init({ loadMaps: true })) ) .pipe(gulpif(prod, streamify(uglify({ compress: { drop_console: true } })))) .pipe( gulpif(createSourcemap(), sourcemaps.write(sourceMapLocation)) ) .pipe( rename({dirname: ''}) ) .pipe(gulpif(prod, cachebust.resources())) .pipe( gulp.dest(config.scripts.dest) ) .pipe( browserSync.stream() ); } return rebundle(); } gulp.task('browserify:Modules', 'Browserify modules', folders(config.modules.src, function(module){ return buildScript(module + '.js'); })); gulp.task('browserify:Main', 'Browserify main app file', function() { return buildScript('app.js'); });
.pipe(gulp.dest('dist/')); }); gulp.task('build-main', function () { return runSequence('main-lint', 'main-templates', 'main-sass', 'main-js'); }); // Cards tasks gulp.task('card-templates', folders('src/cards', function (folder) { return gulp.src(path.join('src/cards', folder, 'templates/**/*.html')) .pipe(plumber()) .pipe(template({ namespace: 'Deckster.Templates', name: function (file) { return file.relative.replace(/(.*\/templates\/|.html)/g, ''); } })) .pipe(concat('templates.js')) .pipe(gulp.dest(path.join('src/cards', folder, 'scripts'))); })); gulp.task('card-sass', folders('src/cards', function (folder) { return gulp.src(path.join('src/cards', folder, 'styles/**/*.scss')) .pipe(sass()) .pipe(autoprefixer()) .pipe(rename(folder + '.css')) .pipe(gulp.dest(path.join('dist/cards', folder))) .pipe(minifycss()) .pipe(rename(folder + '.min.css')) .pipe(gulp.dest(path.join('dist/cards', folder)));