1 Star 0 Fork 0

tr0uble/HomePage

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gulpfile.js 1.96 KB
一键复制 编辑 原始数据 按行查看 历史
const gulp = require('gulp')
const minifycss = require('gulp-clean-css')
const uglify = require('gulp-uglify')
const htmlmin = require('gulp-htmlmin')
const cssnano = require('gulp-cssnano')
const htmlclean = require('gulp-htmlclean')
const del = require('del')
const babel = require('gulp-babel')
const autoprefixer = require('gulp-autoprefixer')
const connect = require('gulp-connect')
const pug = require('gulp-pug')
const sass = require('gulp-sass')
sass.compiler = require('node-sass')
const config = require('./config.json')
gulp.task('clean', function () {
return del(['./dist/css/', './dist/js/'])
})
gulp.task('css', function () {
return gulp
.src('./src/css/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(minifycss({ compatibility: 'ie8' }))
.pipe(autoprefixer({ browsers: ['last 2 version'] }))
.pipe(cssnano({ reduceIdents: false }))
.pipe(gulp.dest('./dist/css'))
})
gulp.task('html', function () {
return gulp
.src('./dist/index.html')
.pipe(htmlclean())
.pipe(htmlmin())
.pipe(gulp.dest('./dist'))
})
gulp.task('js', function () {
return gulp
.src('./src/js/*.js')
.pipe(babel({ presets: ['@babel/preset-env'] }))
.pipe(uglify())
.pipe(gulp.dest('./dist/js'))
})
gulp.task('pug', function () {
return gulp
.src('./src/index.pug')
.pipe(pug({ data: config }))
.pipe(gulp.dest('./dist'))
})
gulp.task('assets', function () {
return gulp
.src(['./src/assets/**/*'])
.pipe(gulp.dest('./dist/assets'));
})
gulp.task('build', gulp.series('clean', 'assets', 'pug', 'css', 'js', 'html'))
gulp.task('default', gulp.series('build'))
gulp.task('watch', function () {
gulp.watch('./src/components/*.pug', gulp.parallel('pug'))
gulp.watch('./src/index.pug', gulp.parallel('pug'))
gulp.watch('./src/css/**/*.scss', gulp.parallel(['css']))
gulp.watch('./src/js/*.js', gulp.parallel(['js']))
connect.server({
root: 'dist',
livereload: true,
port: 8080
})
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tr0ub1e/HomePage.git
git@gitee.com:tr0ub1e/HomePage.git
tr0ub1e
HomePage
HomePage
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385