Skip to content
This repository was archived by the owner on Sep 15, 2023. It is now read-only.

give developers one more option for PHP sites where place the html templates #591

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ Desktop.ini
node_modules
**/generated/_icons.sass
npm-debug.log
.vscode/
.vscode/
.idea
temp
views
2 changes: 1 addition & 1 deletion gulpfile.js/lib/webpack-multi-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = function (env) {
entry: TASK_CONFIG.javascripts.entry,
output: {
path: path.normalize(jsDest),
filename: rev ? '[name]-[hash].js' : '[name].js',
filename: rev ? '[name].js?v=[hash]' : '[name].js',
publicPath: publicPath
},
plugins: [],
Expand Down
4 changes: 3 additions & 1 deletion gulpfile.js/path-config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"src": "./src",
"dest": "./public",
"temp" : "./temp",

"html": {
"src": "html",
"dest": "./"
"dest": "./",
"views" : "../views"
},

"static": {
Expand Down
12 changes: 10 additions & 2 deletions gulpfile.js/tasks/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const htmlTask = function() {
const paths = {
src: [projectPath(PATH_CONFIG.src, PATH_CONFIG.html.src, '**/*.{' + TASK_CONFIG.html.extensions + '}'), exclude],
dest: projectPath(PATH_CONFIG.dest, PATH_CONFIG.html.dest),
viewDest: projectPath(PATH_CONFIG.finalDest?PATH_CONFIG.finalDest:PATH_CONFIG.dest,PATH_CONFIG.html.views ? PATH_CONFIG.html.views : PATH_CONFIG.html.dest)
}

const dataFunction = TASK_CONFIG.html.dataFunction || function(file) {
Expand All @@ -41,17 +42,24 @@ const htmlTask = function() {
if (TASK_CONFIG.html.templateLanguage === 'twig') {
TASK_CONFIG.html.twig.base = TASK_CONFIG.html.twig.base || templateBasePath
templateParser = twig(TASK_CONFIG.html.twig)
} else {
} else if (TASK_CONFIG.html.templateLanguage === 'nunjucks'){
TASK_CONFIG.html.nunjucksRender.path = TASK_CONFIG.html.nunjucksRender.path || templateBasePath
templateParser = nunjucksRender(TASK_CONFIG.html.nunjucksRender)
}else{
return gulp.src(paths.src)
.on('error', handleErrors)
.pipe(gulpif(global.production, htmlmin(TASK_CONFIG.html.htmlmin)))
.pipe(gulp.dest(paths.viewDest))
.pipe(gulp.dest(paths.dest))
.pipe(browserSync.stream())
}

return gulp.src(paths.src)
.pipe(data(dataFunction))
.on('error', handleErrors)
.pipe(templateParser)
.on('error', handleErrors)
.pipe(gulpif(global.production, htmlmin(TASK_CONFIG.html.htmlmin)))
.pipe(gulp.dest(paths.viewDest))
.pipe(gulp.dest(paths.dest))
.pipe(browserSync.stream())
}
Expand Down
8 changes: 8 additions & 0 deletions gulpfile.js/tasks/replace-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ var replaceFiles = function (cb) {

del.sync(delPatterns, { force: true })
fs.copySync(temp, dest)
if(TASK_CONFIG.html && PATH_CONFIG.html.views){
// if you define the html.views
// You can produce the html anywhere you want
var finalHtmlDest = projectPath(PATH_CONFIG.finalDest,PATH_CONFIG.html.views);
var tempHtml = projectPath(PATH_CONFIG.finalDest,PATH_CONFIG.html.dest);
fs.copySync(tempHtml,finalHtmlDest);
del.sync(tempHtml,{ force:true});
}
del.sync(temp, { force: true })

cb()
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js/tasks/rev/rev-assets.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var gulp = require('gulp')
var rev = require('gulp-rev')
var rev = require('gulp-rev-blendme')
var revdel = require('gulp-rev-delete-original')
var projectPath = require('../../lib/projectPath')

Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js/tasks/rev/rev-css.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var gulp = require('gulp')
var rev = require('gulp-rev')
var rev = require('gulp-rev-blendme')
var revdel = require('gulp-rev-delete-original')
var projectPath = require('../../lib/projectPath')

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"gulp-postcss": "^8.0.0",
"gulp-rename": "^1.4.0",
"gulp-replace": "^1.0.0",
"gulp-rev": "9.0.0",
"gulp-rev-blendme": "^9.0.2",
"gulp-rev-delete-original": "^0.2.3",
"gulp-rev-rewrite": "^1.1.4",
"gulp-sass": "^4.0.2",
Expand Down
Loading