Reformat gulpfile
This commit is contained in:
parent
56cbaa4489
commit
7478dc3a9e
1 changed files with 66 additions and 66 deletions
132
gulpfile.js
132
gulpfile.js
|
@ -7,97 +7,97 @@ const sourcemaps = require('gulp-sourcemaps')
|
||||||
const postcss = require('gulp-postcss')
|
const postcss = require('gulp-postcss')
|
||||||
|
|
||||||
const htmlFiles = [
|
const htmlFiles = [
|
||||||
'**/*.html',
|
'**/*.html',
|
||||||
'!**/index.html',
|
'!**/index.html',
|
||||||
'!**/includes/**/*.html',
|
'!**/includes/**/*.html',
|
||||||
'!node_modules/**/*.*',
|
'!node_modules/**/*.*',
|
||||||
'!Carolyns_Creations/**/*.html',
|
'!Carolyns_Creations/**/*.html',
|
||||||
'!vpz_research/**/*.html',
|
'!vpz_research/**/*.html',
|
||||||
]
|
]
|
||||||
|
|
||||||
const cssFiles = [
|
const cssFiles = [
|
||||||
'**/*.css',
|
'**/*.css',
|
||||||
'!style/*.css',
|
'!style/*.css',
|
||||||
'!node_modules/**/*.*',
|
'!node_modules/**/*.*',
|
||||||
'!Carolyns_Creations/**/*.css',
|
'!Carolyns_Creations/**/*.css',
|
||||||
'!vpz_research/**/*.css',
|
'!vpz_research/**/*.css',
|
||||||
]
|
]
|
||||||
|
|
||||||
const postcssPlugins = [
|
const postcssPlugins = [
|
||||||
require('postcss-preset-env')({
|
require('postcss-preset-env')({
|
||||||
enableClientSidePolyfills: true,
|
enableClientSidePolyfills: true,
|
||||||
}),
|
}),
|
||||||
require('cssnano')({
|
require('cssnano')({
|
||||||
preset: 'default',
|
preset: 'default',
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
|
||||||
const posthtmlPlugins = [
|
const posthtmlPlugins = [
|
||||||
require('posthtml-urls')({
|
require('posthtml-urls')({
|
||||||
eachURL: (url) => {
|
eachURL: (url) => {
|
||||||
if (url.endsWith('?@root')) {
|
if (url.endsWith('?@root')) {
|
||||||
return url.replace('?@root', '')
|
return url.replace('?@root', '')
|
||||||
} else if (url.startsWith('/')) {
|
} else if (url.startsWith('/')) {
|
||||||
return `/${site}${url}`
|
return `/${site}${url}`
|
||||||
} else {
|
} else {
|
||||||
return url
|
return url
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
filter: {
|
filter: {
|
||||||
module: {href: true}
|
module: {href: true}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
require('posthtml-postcss')(postcssPlugins, {}, /^text\/css$/)
|
require('posthtml-postcss')(postcssPlugins, {}, /^text\/css$/)
|
||||||
]
|
]
|
||||||
|
|
||||||
let site = ''
|
let site = ''
|
||||||
|
|
||||||
function html() {
|
function html() {
|
||||||
const stream = src(htmlFiles)
|
const stream = src(htmlFiles)
|
||||||
.pipe(tap(file => {
|
.pipe(tap(file => {
|
||||||
const path = file.path.split('/')
|
const path = file.path.split('/')
|
||||||
site = path[path.indexOf('saudade') + 1]
|
site = path[path.indexOf('saudade') + 1]
|
||||||
}))
|
}))
|
||||||
.pipe(posthtml([
|
.pipe(posthtml([
|
||||||
...posthtmlPlugins,
|
...posthtmlPlugins,
|
||||||
require('posthtml-modules')({
|
require('posthtml-modules')({
|
||||||
plugins: posthtmlPlugins
|
plugins: posthtmlPlugins
|
||||||
}),
|
}),
|
||||||
]))
|
]))
|
||||||
.pipe(rename((path) => {
|
.pipe(rename((path) => {
|
||||||
path.basename = 'index'
|
path.basename = 'index'
|
||||||
}))
|
}))
|
||||||
.pipe(dest('.'))
|
.pipe(dest('.'))
|
||||||
|
|
||||||
if (browserSync.active) {
|
if (browserSync.active) {
|
||||||
stream.pipe(browserSync.stream())
|
stream.pipe(browserSync.stream())
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream
|
return stream
|
||||||
}
|
}
|
||||||
|
|
||||||
function css() {
|
function css() {
|
||||||
const stream = src(cssFiles)
|
const stream = src(cssFiles)
|
||||||
.pipe(sourcemaps.init())
|
.pipe(sourcemaps.init())
|
||||||
.pipe(postcss(postcssPlugins))
|
.pipe(postcss(postcssPlugins))
|
||||||
.pipe(rename(path => {
|
.pipe(rename(path => {
|
||||||
path.basename = 'style'
|
path.basename = 'style'
|
||||||
}))
|
}))
|
||||||
.pipe(sourcemaps.write())
|
.pipe(sourcemaps.write())
|
||||||
.pipe(dest('.'))
|
.pipe(dest('.'))
|
||||||
|
|
||||||
if (browserSync.active) {
|
if (browserSync.active) {
|
||||||
stream.pipe(browserSync.stream())
|
stream.pipe(browserSync.stream())
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream
|
return stream
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.watch = function () {
|
exports.watch = function () {
|
||||||
browserSync.init(require('./bs-config'))
|
browserSync.init(require('./bs-config'))
|
||||||
|
|
||||||
watch(htmlFiles, {ignoreInitial: false}, html)
|
watch(htmlFiles, {ignoreInitial: false}, html)
|
||||||
watch(cssFiles, {ignoreInitial: false}, css)
|
watch(cssFiles, {ignoreInitial: false}, css)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.build = parallel(html, css)
|
exports.build = parallel(html, css)
|
||||||
|
|
Loading…
Reference in a new issue