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

Add an additional webroot path setting, used by the rev tasks #452

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ File structure is configued through a **config/path-config.json** file. This fil

This file specifies the `src` and `dest` root directories, and `src` and `dest` for each task, relative to the configured root.

If the public webroot directory is different from the main `dest` directory, you may also specify the `webroot` setting, with the name of the subdirectory, e.g. `public_html`.

A minimal setup might look someting like this:

```json
Expand Down
5 changes: 4 additions & 1 deletion gulpfile.js/lib/webpack-multi-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ module.exports = function (env) {

if (env === 'production') {
if (rev) {
webpackConfig.plugins.push(new webpackManifest(PATH_CONFIG.javascripts.dest, PATH_CONFIG.dest))
var srcPath = PATH_CONFIG.rootPath ?
path.relative(PATH_CONFIG.rootPath, PATH_CONFIG.javascripts.dest) :
PATH_CONFIG.javascripts.dest
webpackConfig.plugins.push(new webpackManifest(srcPath, PATH_CONFIG.dest))
}

const uglifyConfig = TASK_CONFIG.javascripts.production.uglifyJsPlugin
Expand Down
8 changes: 5 additions & 3 deletions gulpfile.js/tasks/rev/rev-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ var revNapkin = require('gulp-rev-napkin');

// 1) Add md5 hashes to assets referenced by CSS and JS files
gulp.task('rev-assets', function() {
var srcPath = path.resolve(process.env.PWD, PATH_CONFIG.dest, PATH_CONFIG.rootPath || '')

// Ignore files that may reference assets. We'll rev them next.
var ignoreThese = '!' + path.resolve(process.env.PWD, PATH_CONFIG.dest,'**/*+(css|js|map|json|html)')
var ignoreThese = '!' + path.resolve(srcPath, '**/*+(css|js|map|json|html|php)')

return gulp.src([path.resolve(process.env.PWD, PATH_CONFIG.dest,'**/*'), ignoreThese])
return gulp.src([path.resolve(srcPath, '**/*'), ignoreThese])
.pipe(rev())
.pipe(gulp.dest(PATH_CONFIG.dest))
.pipe(gulp.dest(srcPath))
.pipe(revNapkin({ verbose: false, force: true }))
.pipe(rev.manifest(path.resolve(process.env.PWD, PATH_CONFIG.dest, 'rev-manifest.json'), {merge: true}))
.pipe(gulp.dest(''))
Expand Down
10 changes: 6 additions & 4 deletions gulpfile.js/tasks/rev/rev-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ var path = require('path')
var rev = require('gulp-rev')
var revNapkin = require('gulp-rev-napkin')

// 4) Rev and compress CSS and JS files (this is done after assets, so that if a
// 4) Rev and compress CSS files (this is done after assets, so that if a
// referenced asset hash changes, the parent hash will change as well
gulp.task('rev-css', function(){
return gulp.src(path.resolve(process.env.PWD, PATH_CONFIG.dest,'**/*.css'))
gulp.task('rev-css', function() {
var srcPath = path.resolve(process.env.PWD, PATH_CONFIG.dest, PATH_CONFIG.stylesheets.dest || '')

return gulp.src(path.resolve(srcPath, '**/*.css'))
.pipe(rev())
.pipe(gulp.dest(PATH_CONFIG.dest))
.pipe(gulp.dest(srcPath))
.pipe(revNapkin({verbose: false, force: true}))
.pipe(rev.manifest(path.resolve(process.env.PWD, PATH_CONFIG.dest, 'rev-manifest.json'), {merge: true}))
.pipe(gulp.dest(''))
Expand Down