Gulp pHTML lets you use pHTML with Gulp.
Add Gulp pHTML to your project:
npm install gulp-phtml --save-dev
Use Gulp pHTML in your Gulpfile:
const gulp = require('gulp')
const gulpPhtml = require('gulp-phtml')
gulp.task('html',
() => gulp.src('./src/*.html').pipe(
gulpPhtml({
/* pHTML Plugins */
plugins: [], // Array | Plugin | Function
/* pHTML Plugins */
processOptions: {} // Object
})
).pipe(
gulp.dest('dist')
)
)
The plugins
property determines which pHTML plugins are applied.
gulpPhtml({
plugins: require('@phtml/image-alt')
})
gulpPhtml({
plugins: [
require('@phtml/image-alt'),
require('@phtml/image-size')({ intrinsicsize: 'intrinsic' })
]
})
The processOptions
property determines which pHTML custom settings are
applied.
gulpPhtml({
processOptions: {
voidElements: ['path', 'source', 'use']
}
})