gulp4 0基本配置

2021-09-05 11:41:01 字數 2440 閱讀 4628

剛開始按照3.0版本,定義task任務後,返回乙個流,但是一直報錯

the following tasks did not complete: ***xx

did you forget to signal async completion

const gulp =

require

('gulp');

const babel =

require

('gulp-babel');

// 語法轉換

const concat =

require

('gulp-concat');

// 合併

const uglify =

require

('gulp-uglify');

// js壓縮

const sass =

require

('gulp-sass'

)// scc編譯

const htmlmin =

require

('gulp-htmlmin');

//html壓縮

const watch =

require

('gulp-watch');

// 監聽檔案

const connect =

require

('gulp-connect');

// 服務

const imagemin =

require

('gulp-imagemin'

)// 壓縮

const del =

require

('del'

)// 清空目錄

const minifycss =

require

('gulp-minify-css'

)//css壓縮

// es6語法轉換 js壓縮 md5命名

gulp.

task

('js'

,async()

=>))

.pipe

(uglify()

).pipe

(gulp.

dest

('./dist/js'))

.pipe

(connect.

reload()

)});

// scss編譯成css

gulp.

task

("scss"

,async()

=>);

// scc合併壓縮

gulp.

task

("css"

,async()

=>))

.pipe

(gulp.

dest

('./dist/css'))

.pipe

(connect.

reload()

)})/

/ 壓縮

gulp.

task

('img'

,async()

=>

)// html壓縮

gulp.

task

('html'

,async()

=>))

.pipe

(gulp.

dest

('dist/'))

.pipe

(connect.

reload()

)});

gulp.

task

('clean'

,async()

=>

)//服務

gulp.

task

('connect'

,function()

);})

;//監視檔案, 自動執行

gulp.

task

('mywatch'

,function()

)//啟動開發環境 gulp.series是順序執行 gulp.parallel是同步執行

gulp.

task

('start'

, gulp.

series

(gulp.

parallel

('mywatch'

,'connect'))

);// 構建專案

gulp.

task

('dist'

,gulp.

series

('clean'

,gulp.

parallel

('html'

,'scss'

,'css'

,'js'

,'img'))

);

gulp基本入門

gulp是乙個前端自動化構建的乙個工具 1.前置 1.1在使用gulp之前,先安裝node和npm 2.安裝gulp 2.1 npm install gulp 3.打包專案 3.1 新建gulpfile.js 獲取 gulp var gulp require gulp 獲取 uglify 模組 用於...

gulp基本使用

gulp強調的是前端開發的工作流程,我們可以通過定義task事件定義事件的執行順序,gulp去執行這些事件,構建整個前端開發的工作流程 gulp常見定義事件,例如 下面會說幾個常見的gulp模組,列舉功能和例子,希望你看完本章後能對gulp有個基本的掌握,能參照這裡的寫法,當需要使用時去官網上會自主...

gulp常用配置

由於專案中經常會使用到gulp,而每次配置大概都差不多,所以將配置記錄一下 dist assets css images js node modules src assets css echarts js odometer 外掛程式等 less images js gulp 自動化任務 var gu...