const postcssUrl = require('postcss-url')
const postcssVar = require('postcss-custom-properties')
const uglify = require('gulp-uglify')
-const sourcemaps = require('gulp-sourcemaps')
const vfs = require('vinyl-fs')
module.exports = (src, dest, preview) => () => {
const opts = { base: src, cwd: src }
+ const sourcemaps = preview || process.env.SOURCEMAPS === 'true'
const postcssPlugins = [
postcssImport(),
postcssUrl([
return merge(
vfs
- .src('js/+([0-9])-*.js', opts)
- .pipe(sourcemaps.init())
+ .src('js/+([0-9])-*.js', { ...opts, sourcemaps })
.pipe(uglify())
- .pipe(concat('js/site.js'))
- .pipe(sourcemaps.write('.')),
+ .pipe(concat('js/site.js')),
vfs
.src('js/vendor/*.js', { ...opts, read: false })
.pipe(
vfs.src('helpers/*.js', opts),
vfs.src('layouts/*.hbs', opts),
vfs.src('partials/*.hbs', opts)
- ).pipe(vfs.dest(dest))
+ ).pipe(vfs.dest(dest, { sourcemaps: sourcemaps && '.' }))
}
"gulp-eslint": "~5.0",
"gulp-imagemin": "~5.0",
"gulp-postcss": "~8.0",
- "gulp-sourcemaps": "~2.6",
"gulp-stylelint": "~8.0",
"gulp-uglify": "~3.0",
"gulp-vinyl-zip": "~2.1 >=2.1.2",