Giter VIP home page Giter VIP logo

blog's People

Contributors

lkiarest avatar

Watchers

 avatar  avatar

blog's Issues

基本的gulp配置

为了不用每次写一些小页面的时候都要重新配一把,保存一份待复用。

gulpfile.js

var path = require('path')
var gulp = require('gulp')
var rename = require("gulp-rename")
var cleanCSS = require('gulp-clean-css')
var less = require('gulp-less')
var LessAutoprefix = require('less-plugin-autoprefix')
var autoprefix = new LessAutoprefix({ browsers: ['>5%'] })
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');

gulp.task('style', function(cb) {
  return gulp.src('style/main.less')
    .pipe(less({
      paths: [path.join(__dirname, 'less', 'includes')],
      plugins: [autoprefix]
    }))
    .pipe(cleanCSS())
    .pipe(rename('index.min.css'))
    .pipe(gulp.dest('./dist/'))
})

gulp.task('script', function(cb) {
  return gulp.src(['script/flexible.js', 'script/main.js'])
    .pipe(uglify())
    .pipe(rename({suffix: '.min'}))
    .pipe(gulp.dest('./dist/'))
})

gulp.task('watch', function(cb) {
  gulp.watch('style/main.less', ['style'])
  gulp.watch('script/main.js', ['script'])
})

gulp.task('default', ['style', 'script', 'watch'])

package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "test page",
  "main": "index.js",
  "author": "qintx",
  "scripts": {
    "build": "gulp"
  },
  "devDependencies": {
    "gulp": "^3.9.1",
    "gulp-clean-css": "^3.9.0",
    "gulp-concat": "^2.6.1",
    "gulp-less": "^3.3.2",
    "gulp-rename": "^1.2.2",
    "gulp-uglify": "^3.0.0",
    "less-plugin-autoprefix": "^1.5.1"
  }
}

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.