Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【资源帖】Gulp入门指南 #439

Open
whqet opened this issue Oct 11, 2018 · 2 comments
Open

【资源帖】Gulp入门指南 #439

whqet opened this issue Oct 11, 2018 · 2 comments

Comments

@whqet
Copy link
Contributor

whqet commented Oct 11, 2018

  1. 需要安装node.js运行环境,没有下载可以到官方下载
  2. 安装gulp.js,步骤参考官方网站新版
  3. cnpm使用,使用淘宝的npm镜像
@zptcsoft
Copy link
Collaborator

zptcsoft commented Oct 12, 2018

上课的时候用到的package.json

{
  "name": "web",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "babel-preset-env": "^1.7.0",
    "gulp": "^3.9.1",
    "gulp-babel": "^7.0.1",
    "gulp-uglify": "^3.0.1",
    "pump": "^3.0.0"
  }
}

@zptcsoft
Copy link
Collaborator

上课时用到的gulpfile.js

const gulp = require('gulp');
const uglify = require('gulp-uglify');
const babel = require('gulp-babel');
const pump = require('pump');


gulp.task('default',function(){
	console.log('ok');
})

gulp.task('compress', function (cb) {
  pump([
        gulp.src('js/*.js'),
        babel({
            "presets": ["env"]
        }),
        uglify(),
        gulp.dest('dist')
    ],
    cb
  );
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants