代码拉取完成,页面将自动刷新
const gulp = require('gulp')
const nodemon = require('gulp-nodemon')
const browserSync = require('browser-sync').create()
const less = require('gulp-less')
gulp.task('less', () => {
return gulp.src('./assets/styles/main.less')
.pipe(less())
.pipe(gulp.dest('./styles'))
})
gulp.task('copy_media', () => {
return gulp.src('./assets/media/**/*')
.pipe(gulp.dest('./media'))
})
gulp.task('gulp_nodemon', () => {
nodemon({
script: 'app.js' // this is where my express server is
, ext: 'js html css ejs less' // nodemon watches *.js, *.html, *.css, *.ejs, *.less files
, env: { 'NODE_ENV': 'development' }
})
})
gulp.task('sync', () => {
browserSync.init({
port: 3002, // this can be any port, it will show our app
proxy: 'http://localhost:3001/', // this is the port where express server works
ui: { port: 3003 }, // UI, can be any port
reloadDelay: 1000 // Important, otherwise syncing will not work
})
gulp.watch([
'./assets/media/**/*'
]).on('change', () => {
return gulp.src('./assets/media/**/*')
.pipe(gulp.dest('./media'))
})
gulp.watch([
'./**/*.less',
]).on('change', () => {
return gulp.src('./assets/styles/main.less')
.pipe(less())
.pipe(gulp.dest('./styles'))
})
gulp.watch([
'./**/*.js',
'./**/*.html',
'./**/*.css',
'./**/*.ejs'
]).on("change", browserSync.reload)
});
// gulp.task('default', ['gulp_nodemon', 'sync'])
gulp.task('default', gulp.parallel('gulp_nodemon', 'copy_media', 'less', 'sync'))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。