1. npm (node package management):node ?的包管理
(1):Use npm to install, share, and distribute code;用node可以安裝拼缝,分享,構(gòu)建代碼
ex: npm install gulp ? 舉例npm安裝gulp
npm install gulp -g
npm 全局安裝:為什么要全局安裝悠夯?
因為如果全局安裝的話胜茧,可以在電腦任何地方用斩萌;ex:npm install http-server -g?
npm install gulp --save-dev ? ?npm安裝gulp保存到此設(shè)備
為什么后面要加 --save-dev ? ?
如果npm install 后面加 --save-dev抹沪,可以在package.json里面的devDependencies 可以看到 包管理:gulp-imagemin,gulp-scss,gulp;
(2) manage dependencies in your projects;?
npm install gulp --save-dev
gulp file.js
vargulp =require('gulp');
varsass =require('gulp-sass');
varimagemin =require('gulp-imagemin');
gulp.task('sass',function() {
returngulp.src('./src/scss/*.scss')
.pipe(sass().on('error',sass.logError))
.pipe(gulp.dest('./dist/css'));
});
gulp.task('sass:watch',function() {
gulp.watch('./src/scss/*.scss',['sass']);
});
gulp.task('package-js',function() {
gulp.src('./src/js/*.js')
.pipe(gulp.dest('./dist/js'));
});
gulp.task('package-html',function() {
gulp.src('./src/index.html')
.pipe(gulp.dest('./dist'));
});
gulp.task('package-image',function() {
gulp.src('./src/assets/*.png')
.pipe(gulp.dest('./dist/assets'));
});
gulp.task('develop',['sass','package-js','package-html','package-image']);
(3) and share & receive feedback with others.