diff --git a/README.md b/README.md index 22c1e890a..e26775c43 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,8 @@ File structure is configured through a **config/path-config.json** file. This fi 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 something like this: ```json diff --git a/gulpfile.js/lib/webpack-multi-config.js b/gulpfile.js/lib/webpack-multi-config.js index 17922b71a..98b98a0a3 100644 --- a/gulpfile.js/lib/webpack-multi-config.js +++ b/gulpfile.js/lib/webpack-multi-config.js @@ -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.webroot ? + path.relative(PATH_CONFIG.webroot, PATH_CONFIG.javascripts.dest) : + PATH_CONFIG.javascripts.dest + webpackConfig.plugins.push(new webpackManifest(srcPath, PATH_CONFIG.dest)) } const uglifyConfig = TASK_CONFIG.javascripts.production.uglifyJsPlugin diff --git a/gulpfile.js/tasks/rev/rev-assets.js b/gulpfile.js/tasks/rev/rev-assets.js index 12efbb844..2bcf8742e 100644 --- a/gulpfile.js/tasks/rev/rev-assets.js +++ b/gulpfile.js/tasks/rev/rev-assets.js @@ -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.webroot || '') + // 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)') - 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('')) diff --git a/gulpfile.js/tasks/rev/rev-css.js b/gulpfile.js/tasks/rev/rev-css.js index d01003acf..6dec9c94b 100644 --- a/gulpfile.js/tasks/rev/rev-css.js +++ b/gulpfile.js/tasks/rev/rev-css.js @@ -3,12 +3,14 @@ var path = require('path') var rev = require('gulp-rev') var revNapkin = require('gulp-rev-napkin') -// 3) 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(''))