2023-06-13 18:17:41 -07:00
|
|
|
const {src, dest, watch} = require('gulp')
|
|
|
|
const posthtml = require('gulp-posthtml')
|
|
|
|
const rename = require('gulp-rename')
|
|
|
|
const browserSync = require('browser-sync').create()
|
|
|
|
|
2023-06-14 20:11:17 -07:00
|
|
|
const htmlFiles = [
|
|
|
|
'sues_virtual_life/**/*.html',
|
|
|
|
'!sues_virtual_life/**/index.html',
|
|
|
|
]
|
2023-06-13 18:17:41 -07:00
|
|
|
|
|
|
|
function html() {
|
2023-06-14 20:11:17 -07:00
|
|
|
const stream = src(htmlFiles)
|
2023-06-13 18:17:41 -07:00
|
|
|
.pipe(posthtml([
|
|
|
|
require('posthtml-urls')({
|
2023-06-14 12:18:54 -07:00
|
|
|
eachURL: (url) => {
|
|
|
|
if (url[0] === '/' && url !== '/menu.js') {
|
|
|
|
return `/sues_virtual_life${url}`
|
|
|
|
} else {
|
|
|
|
return url
|
|
|
|
}
|
|
|
|
},
|
2023-06-13 18:17:41 -07:00
|
|
|
}),
|
|
|
|
]))
|
|
|
|
.pipe(rename(path => {
|
|
|
|
path.basename = 'index'
|
|
|
|
}))
|
2023-06-14 20:11:17 -07:00
|
|
|
.pipe(dest('sues_virtual_life'))
|
|
|
|
|
|
|
|
if (browserSync.active) {
|
|
|
|
stream.pipe(browserSync.stream())
|
|
|
|
}
|
|
|
|
|
|
|
|
return stream
|
2023-06-13 18:17:41 -07:00
|
|
|
}
|
|
|
|
|
2023-06-14 20:11:17 -07:00
|
|
|
exports.watch = function () {
|
2023-06-13 18:17:41 -07:00
|
|
|
browserSync.init(require('../bs-config'))
|
|
|
|
|
|
|
|
watch(htmlFiles, {ignoreInitial: false}, html)
|
2023-06-14 12:18:54 -07:00
|
|
|
watch('sues_virtual_life.css').on('change', browserSync.reload)
|
2023-06-13 18:17:41 -07:00
|
|
|
}
|
2023-06-14 20:11:17 -07:00
|
|
|
|
|
|
|
exports.build = html
|