gulp.task('yandex-config-copy', function () { return gulp.src(['./tmp/build/yandex/**/*']) .pipe(ignore.exclude('**/*.js')) .pipe(ignore.exclude('**/*.json')) .pipe(ignore.exclude('**/*.html')) .pipe(gulp.dest('./tmp/dev/yandex')); });
gulp.task('vivaldi-config-copy', function () { return gulp.src(['./tmp/build/vivaldi/**/*']) .pipe(ignore.exclude('**/*.js')) .pipe(ignore.exclude('**/*.json')) .pipe(ignore.exclude('**/*.html')) .pipe(gulp.dest('./tmp/dev/vivaldi')); });
gulp.task('opera-config-copy', function () { return gulp.src(['./build/opera/**/*']) .pipe(ignore.exclude('**/*.js')) .pipe(ignore.exclude('**/*.json')) .pipe(ignore.exclude('**/*.html')) .pipe(gulp.dest('./config/opera')); });
gulp.task('firefox-config-copy', function () { return gulp.src(['./build/firefox/**/*']) .pipe(ignore.exclude('**/*.js')) .pipe(ignore.exclude('**/*.json')) .pipe(ignore.exclude('**/*.html')) .pipe(gulp.dest('./config/firefox')); });
gulp.task('safari-config-copy', function () { return gulp.src(['./tmp/build/safari/**/*']) .pipe(ignore.exclude('**/*.js')) .pipe(ignore.exclude('**/*.json')) .pipe(ignore.exclude('**/*.html')) .pipe(ignore.exclude('**/*.plist')) .pipe(gulp.dest('./tmp/dev/safari')); });
gulp.task('lint', function () { return gulp.src(sources) .pipe(ignore.exclude(/angular\.js/)) .pipe(ignore.exclude(/angular-confirm\.js/)) .pipe(ignore.exclude(/ui-bootstrap-tpls\.js/)) .pipe(jshint({"predef": ["angular"]})) .pipe(jshint.reporter('default')) .pipe(jshint.reporter('fail'));; });
gulp.task('bower', function() { return $.bower() .pipe(exclude('**/.*')) .pipe(exclude('**/*.md')) .pipe(exclude('**/*.json')) .pipe(exclude('**/*.coffee')) .pipe(exclude('**/src/**')) .pipe(gulp.dest('dist/lib')); });
gulp.task('bower:copy', ['clean:lib'], function() { return gulp.src(mainBowerFiles(), {base: paths.src.bower}) // no need to serve source files: they will be bundled in one js and one css .pipe(_ignore.exclude(["**/*.less"])) .pipe(imagemin()) // ignore non-images, compress images from libs .pipe(gulp.dest(paths.dst.bower)); });
module.exports = function () { var jsManifest = gulp.src('./static/allegation/js/rev-manifest.json'); var cssManifest = gulp.src('./static/css/rev-manifest.json'); return gulp.src(['./allegation/templates/allegation/index.html']) .pipe(replace(/<!-- build(?:.|\s)+?<!-- endbuild/g, replaceFunc)) .pipe(useref({ searchPath: '.' })) .pipe(gulpif('index.html', source('index.html') .pipe(replace(/(<script src=")(js\/combined.js)/g, '$1{% static \'$2\' %}')) )) .pipe(gulpif('index.html', source('index.html') .pipe(replace(/(<link.+? href=")(css\/combined.css)/g, '$1{% static \'$2\' %}')) )) .pipe(gulpif('index.html', source('index.html') .pipe(revReplace({manifest: jsManifest})) )) .pipe(gulpif('index.html', source('index.html') .pipe(revReplace({manifest: cssManifest})) )) .pipe(gulpif('index.html', source('index.html') .pipe(gulp.dest('templates/allegation')) )) .pipe(ignore.exclude('index.html')) .pipe(gulpif('*.js', uglify())) .pipe(gulp.dest('static')); };
gulp.task("min:js", function () { return gulp.src([paths.js, "!" + paths.minJs], { base: "." }) .pipe(concat(paths.concatJsDest)) .pipe(ignore.exclude(["**/*.map"])) .pipe(uglify().on('error', util.log)) .pipe(gulp.dest(".")); });
gulp.task('sass', () => gulp .src(config.globalPaths.src + config.sourcePaths.styles + '/main.scss') .pipe(rename('listGraph.css')) .pipe(flatten()) .pipe(sass().on('error', sass.logError)) .pipe(gulp.dest(config.globalPaths.dist)) // Exclude everything when we are not in production mode. .pipe( gulpIf( !production, ignore.exclude('*') ) ) // Rename file .pipe(rename({ suffix: '.min' })) .pipe(sourcemaps.init()) // Add vendor prefixes in production mode .pipe(autoprefixer({ browsers: config.browsers, cascade: true })) // Minify stylesheet in production mode .pipe(cleanCss()) // Write sourcemap .pipe(sourcemaps.write('.')) .pipe(gulp.dest(config.globalPaths.dist))
var html = function(source, dest) { return gulp.src(source) .pipe(plumber({errorHandler: onError})) // Do not copy BEM modifiers and elements .pipe(gulpIgnore.exclude(function(file) { if ((file.path.indexOf('--') !== -1) || (file.path.indexOf('__') !== -1)) { return true; } })) // SEO friendly urls .pipe(rename(function(path) { // rename home/home.html > index.html if (path.dirname == 'home') { path.dirname = ''; } // rename work/work.html > work/index.html path.basename = 'index'; // rename not-found/index.html > 404.html if (path.dirname == 'not-found') { path.dirname = ''; path.basename = '404'; } })) .pipe(minifyHTML()) .pipe(gulp.dest(dest)); }
gulp.task('sass', function() { return sass('./scss/main.scss', { sourcemap: true }) .pipe(sourcemaps.write('./', { includeContent: false, sourceRoot: '/scss' })) .pipe(gulp.dest('./css')) .pipe(gulpIgnore.exclude(function(file) { if (file.path.indexOf('.map') !== -1) { return true; } else { return false; } })) .pipe(minifyCss()) .pipe(rename({ extname: '.min.css' })) .pipe(gulp.dest('./css')) .on('error', function (err) { console.error(err.message); }) .pipe(connect.reload()); });
gulp.task('compress', function() { var fileList = [ //Components './app/components/**', //Factories './app/factories/**', //Services './app/services/**', //Config './app/config/config.js', //mainApp './app/app.js' ]; return gulp.src(fileList) .pipe(gulpIgnore.exclude('*.html')) .pipe(sourcemaps.init()) .pipe(concat('concat.js')) .pipe(rename('app.min.js')) .pipe(ngAnnotate()) .pipe(uglify({ mangle: true })) .pipe(sourcemaps.write('./maps')) .pipe(gulp.dest('app')); });
packageCss: function(options) { var sourceExtension = path.extname(options.source), targetExtension = '.css', baseName = path.basename(options.source, sourceExtension), targetPath = '../../' + options.targetDirectory + '/' + baseName + targetExtension, targetFile = path.resolve(__dirname, targetPath), patternLibraryPath = options.patternLibraryPath, packageConfig = _.extend( {}, webpackConfigCSS, { entry: {}, output: { filename: targetFile, chunkFilename: baseName + '-[id]' + targetExtension } } ); if (patternLibraryPath) { packageConfig.sassLoader.data = '$pattern-library-path: \'' + patternLibraryPath + '\' !default;'; } packageConfig.entry[baseName + targetExtension] = path.resolve(__dirname, '../../' + options.source); return gulp.src('') .pipe(webpack(packageConfig)) .pipe(gulpIgnore.exclude('**/*.js')) // Exclude JavaScript files that are generated .pipe(gulp.dest(options.targetDirectory)); }
function discardIfExists(path) { if (fs.existsSync(path)) { return ignore.exclude('**') } else { return ignore.include('**') } }
gulp.task('sass', function () { return gulp.src(gulpPath.to.sass.main) .pipe(sass()) .on('error', error.handler) .pipe(prefix(['last 2 versions', 'IE 9'], { cascade: true })) .on('error', error.handler) .pipe(gulp.dest(gulpPath.to.sass.destination)) .pipe(gulpIgnore.exclude(gulpPath.to.css.alreadyMinified)) .pipe(plumber()) .pipe(rename({ suffix: '.min' })) .pipe(cleanCSS({ debug: true, compatibility: 'ie9', keepSpecialComments: 1 }, function (details) { console.log(details.name + ': ' + details.stats.originalSize) console.log(details.name + ': ' + details.stats.minifiedSize) })) .pipe(gulp.dest(gulpPath.to.css.destination)) // .pipe(browserSync.reload({stream: true})) })
gulp.task('jade', function() { gulp.src('./assets/src/templates/**/*.jade') .pipe(gulpIgnore.exclude(jade_except)) .pipe(jade()) .pipe(gulp.dest('./')) .pipe(browserSync.stream()) });
gulp.task('website:css', ()=> { gulp.src(siteDir + 'css/*.css') .pipe(gulpIgnore.exclude('*.min.css')) .pipe(cssmin()) .pipe(rename({suffix: '.min'})) .pipe(gulp.dest(siteDir + 'css')); });
gulp.task('build-index', function(){ var importsToAdd = []; var files = [ 'dialog-options.js', 'resources/ai-dialog-body.js', 'resources/ai-dialog-footer.js', 'resources/ai-dialog-header.js', 'resources/ai-dialog.js', 'resources/attach-focus.js', 'lifecycle.js', 'dialog-controller.js', 'renderers/renderer.js', 'renderers/dialog-renderer.js', 'dialog-service.js', 'dialog-configuration.js', 'aurelia-dialog.js' ].map(function(file){ return paths.root + file; }); return gulp.src(files) .pipe(gulpIgnore.exclude('aurelia-dialog.js')) .pipe(through2.obj(function(file, enc, callback) { file.contents = new Buffer(tools.extractImports(file.contents.toString("utf8"), importsToAdd)); this.push(file); return callback(); })) .pipe(concat(jsName)) .pipe(insert.transform(function(contents) { return tools.createImportBlock(importsToAdd) + contents; })) .pipe(gulp.dest(paths.output)); });
], function() { return gulp.src(['docoloo/**/*.{ico,css,js,png,jpg,gif}']) .pipe(ignore.exclude(/-[a-f0-9]{8,}\.(css|js|png|jpg|gif)$/)) .pipe(rev()) .pipe(gulp.dest('docoloo')) .pipe(rev.manifest('manifest.json')) .pipe(gulp.dest('docoloo')); });
function modulesTask() { var exclude = config.globs.npmAssetsExclude ? ignore.exclude(config.globs.npmAssetsExclude) : identity(); return gulp.src(config.globs.npmAssets, { base: './', buffer: false }) .pipe(exclude) .pipe(errorHandler()) .pipe(gulp.dest(config.paths.out)) ; }
gulp.task("copy-lib", ["clean:lib"], function () { var ignoreComponents = ["**/npm.js"]; for (var desDir in bower) gulp.src(paths.host.bower + bower[desDir]) .pipe(ignore.exclude(ignoreComponents)) .pipe(gulp.dest(paths.host.lib + desDir)); });
gulp.task('resource:server', function() { // 拷贝 server 部分无需转码代码到输出路径 return gulp.src([ libPath.join(PATH.src.server.path, '**', '*'), libPath.join('!' + PATH.src.server.es6, '**', '*') ]) .pipe(gulpif(IS_PRODUCTION, ignore.exclude(libPath.join(PATH.src.server.boot, 'explorer.js')))) // 在生产环境不使用 explorer.js .pipe(gulp.dest(PATH.dest.server.path)); });
gulp.task('jade', function() { gulp.src(paths.jade) //.pipe(filelog('JADE:::::::BEFORE')) .pipe(gulpIgnore.exclude(/app\/jade\/partials\/(.*)\.jade/)) //.pipe(filelog('JADE:::::::AFTER')) .pipe(jade({pretty: true})) .pipe(gulp.dest('www/')); });
function lintTask() { var exclude = config.globs.lineExclude ? ignore.exclude(config.globs.lintExclude) : identity(); return gulp.src(['*.js', '**/*.js', '!node_modules/**', '!bower_components/**', '!' + config.paths.out + '/**']) .pipe(exclude) .pipe(errorHandler()) .pipe(jshint()) .pipe(jshint.reporter(jshintReporter)) ; }
gulp.task('optimize:js', function() { return gulp.src([config.src]) //.pipe(hint()) //.pipe(hint.reporter()) .pipe(gulpIgnore.exclude(config.ignore)) .pipe(minifyjs(config.options)) .pipe(gulp.dest(config.dest)) .pipe(size()); });
gulp.task('build-index', function(){ var importsToAdd = []; return gulp.src(paths.source) .pipe(tools.sortFiles()) .pipe(gulpIgnore.exclude('aurelia-validatejs.js')) .pipe(gulpIgnore.exclude('index.js')) .pipe(through2.obj(function(file, enc, callback) { file.contents = new Buffer(tools.extractImports(file.contents.toString("utf8"), importsToAdd)); this.push(file); return callback(); })) .pipe(concat(jsName)) .pipe(insert.transform(function(contents) { return tools.createImportBlock(importsToAdd) + contents; })) .pipe(gulp.dest(paths.output)); });
gulp.task('replace-html', ['lint'], function() { return gulp.src('public/src/index.html') .pipe(useref({}, lazypipe().pipe(sourcemaps.init))) .pipe(gulpif('*.css', cssnano())) .pipe(ignore.exclude('public/src/js/lib/*.js')) .pipe(gulpif('*.js', uglify({preserveComments: 'license'}))) .pipe(sourcemaps.write('.')) .pipe(gulp.dest('public/dist')); });
gulp.task('build', function () { gulp.src(['libs/*', 'dist/pptxgen.js']) .pipe(concat('pptxgen.bundle.js')) .pipe(sourcemaps.init()) .pipe(ignore.exclude(["**/*.map"])) .pipe(uglify()) .pipe(sourcemaps.write('./')) .pipe(gulp.dest('dist/')); });