代码拉取完成,页面将自动刷新
const { src, task, dest, parallel } = require('gulp')
const babel = require('gulp-babel')
const uglify = require('gulp-uglify')
const imagemin = require('gulp-imagemin')
// 加载dotenv模块
// 具体用法可以查看文档
require('dotenv').config()
// console.log(process.env)
const sourceFiles = ['./assets/libs/*.*']
const Copy = cb => {
src(sourceFiles).pipe(dest('./dist/m/libs'))
cb()
}
task(Copy)
const mCss = cb => {
src(['./assets/css/*.css']).pipe(dest('./dist/m/css'))
cb()
}
task(mCss)
const mJs = cb => {
src(['./assets/js/*.js', './assets/js/**/*.js'])
.pipe(
babel({
presets: ['@babel/preset-env']
})
)
.pipe(uglify())
.pipe(dest('./dist/m/js'))
cb()
}
task(mJs)
const mImg = cb => {
src('./assets/img/**/*')
.pipe(
imagemin([
imagemin.gifsicle({ interlaced: true }),
imagemin.mozjpeg({ quality: 75, progressive: true }),
imagemin.optipng({ optimizationLevel: 5 }),
imagemin.svgo({
plugins: [{ removeViewBox: true }, { cleanupIDs: false }]
})
])
)
.pipe(dest('./dist/m/img'))
cb()
}
task(mImg)
exports.buildImg = mImg
exports.build = parallel(Copy, mCss, mJs, mImg)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。