Giter Site home page Giter Site logo

gulpfiledemo's Introduction

gulpfiledemo

var del = require('del'); var gulp = require('gulp'); var inlineNg2Template = require('gulp-inline-ng2-template'); var ts = require('gulp-typescript'); var runsequence = require('run-sequence'); var uglify = require('gulp-uglify'); var rimraf = require('rimraf'); var template = require('gulp-template'); var inject = require('gulp-inject'); var watch = require('gulp-watch');

/**

  • verson control */ var bump = require('gulp-bump'); var semver = require('semver'); var fs = require('fs');

var paths = { build : 'dist/build', base : 'src/app/reporting/', ts : ['src/app//*.ts','!src/app//.spec.ts'], test_ts : ['src/app/**/.spec.ts','!src/app/**/*.ts'] };

gulp.task('hello',()=>{ console.log("Hello World"); })

gulp.task('clean',() => { del(paths.build); });

gulp.task('clean2',(done)=>{ rimraf(paths.build,()=>{ console.log("removed"); }); });

gulp.task('template',(done)=>{ gulp.src('src/app/app.component.html') .pipe(template({name:'Riveryyyy'})) .pipe(gulp.dest('dist/tmp')); });

/**

  • 可以 用来引入一些静态资源,以及第三方库 / gulp.task('inject', ()=>{ var target = gulp.src('src/index.html'); var sources = gulp.src(['./src/**/.js', './src/**/*.css'], {read: false}); target.pipe(inject(sources)) .pipe(gulp.dest(paths.build)); });

gulp.task('inline',function(done){ gulp.src(paths.ts) .pipe(inlineNg2Template({useRelativePaths:true})) .pipe(ts()) .pipe(uglify()) .pipe(gulp.dest(paths.build)); done; });

gulp.task('compile-typescript',()=>{ return gulp.src(paths.ts) .pipe(inlineNg2Template({useRelativePaths:true})) .pipe(ts()) .pipe(uglify()) .pipe(gulp.dest(paths.build)); })

gulp.task('watch',function(done){ return gulp.watch(paths.ts,['compile-typescript'],{ ignoreInitial: false },()=>{ console.log('watched'); }) });

gulp.task('compile',(cb)=>{ runsequence( 'hello', 'clean', 'inline', cb ); });

var getPackageJson = function () { return JSON.parse(fs.readFileSync('./package.json', 'utf8')); };

// bump versions on package/bower/manifest gulp.task('bump', function () { // reget package var pkg = getPackageJson(); // increment version var newVer = semver.inc(pkg.version, 'patch');

return gulp.src('./package.json') .pipe(bump({ version: newVer })) .pipe(gulp.dest('./')); });

gulpfiledemo's People

Contributors

xigongdaericyang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.