const jsFiles = [
'gulpfile.js',
'tasks/**/*.js',
- path.join(srcDir, '{helpers,js}/**/*.js')
+ path.join(srcDir, '{helpers,js}/**/*.js'),
]
-gulp.task('lint', () =>
- lint(jsFiles)
-)
+gulp.task('lint', () => lint(jsFiles))
-gulp.task('format', () =>
- format(jsFiles)
-)
+gulp.task('format', () => format(jsFiles))
-gulp.task('build', () =>
- build(srcDir, destDir)
-)
+gulp.task('build', () => build(srcDir, destDir))
gulp.task('build:preview', ['build'], () =>
buildPreview(srcDir, destDir, previewSiteSrcDir, previewSiteDestDir)
})
)
-gulp.task('pack', ['build', 'lint'], () =>
- pack(destDir, buildDir, bundleName)
-)
+gulp.task('pack', ['build', 'lint'], () => pack(destDir, buildDir, bundleName))
gulp.task('default', ['build'])
const mockUIModel = loadSampleUIModel(siteSrc)
- vfs.src('**/*.html', { base: siteSrc, cwd: siteSrc })
- .pipe(map((file, next) => {
- const compiledLayout = layouts['default.hbs']
- const siteRootPath = path.relative(path.dirname(file.path), path.resolve(siteSrc))
- mockUIModel['siteRootPath'] = siteRootPath
- mockUIModel['siteRootUrl'] = path.join(siteRootPath, 'index.html')
- mockUIModel['uiRootPath'] = path.join(siteRootPath, '_')
- mockUIModel['contents'] = file.contents.toString().trimRight()
- file.contents = Buffer.from(compiledLayout(mockUIModel))
- next(null, file)
- }))
+ vfs
+ .src('**/*.html', { base: siteSrc, cwd: siteSrc })
+ .pipe(
+ map((file, next) => {
+ const compiledLayout = layouts['default.hbs']
+ const siteRootPath = path.relative(
+ path.dirname(file.path),
+ path.resolve(siteSrc)
+ )
+ mockUIModel['siteRootPath'] = siteRootPath
+ mockUIModel['siteRootUrl'] = path.join(siteRootPath, 'index.html')
+ mockUIModel['uiRootPath'] = path.join(siteRootPath, '_')
+ mockUIModel['contents'] = file.contents.toString().trimRight()
+ file.contents = Buffer.from(compiledLayout(mockUIModel))
+ next(null, file)
+ })
+ )
.pipe(vfs.dest(siteDest))
}
function registerPartials (src) {
return new Promise((resolve, reject) => {
- vfs.src(['partials/*.hbs'], { base: src, cwd: src })
- .pipe(map((file, next) => {
- handlebars.registerPartial(file.stem, file.contents.toString())
- next(null, file)
- }))
+ vfs
+ .src(['partials/*.hbs'], { base: src, cwd: src })
+ .pipe(
+ map((file, next) => {
+ handlebars.registerPartial(file.stem, file.contents.toString())
+ next(null, file)
+ })
+ )
.on('error', reject)
.on('end', resolve)
})
function registerHelpers (src) {
return new Promise((resolve, reject) => {
- vfs.src(['helpers/*.js'], { base: src, cwd: src })
- .pipe(map((file, next) => {
- const helperFunction = requireFromString(file.contents.toString())
- handlebars.registerHelper(file.stem, helperFunction)
- next(null, file)
- }))
+ vfs
+ .src(['helpers/*.js'], { base: src, cwd: src })
+ .pipe(
+ map((file, next) => {
+ const helperFunction = requireFromString(file.contents.toString())
+ handlebars.registerHelper(file.stem, helperFunction)
+ next(null, file)
+ })
+ )
.on('error', reject)
.on('end', resolve)
})
function compileLayouts (src) {
const layouts = {}
return new Promise((resolve, reject) => {
- vfs.src('layouts/*.hbs', { base: src, cwd: src })
- .pipe(map((file, next) => {
- layouts[file.basename] = handlebars.compile(file.contents.toString(), { preventIndent: true })
- next(null, file)
- }))
+ vfs
+ .src('layouts/*.hbs', { base: src, cwd: src })
+ .pipe(
+ map((file, next) => {
+ layouts[file.basename] = handlebars.compile(
+ file.contents.toString(),
+ { preventIndent: true }
+ )
+ next(null, file)
+ })
+ )
.on('error', reject)
.on('end', () => resolve(layouts))
})
}
function loadSampleUIModel (siteSrc) {
- return yaml.safeLoad(fs.readFileSync(path.join(siteSrc, 'ui-model.yml'), 'utf8'))
+ return yaml.safeLoad(
+ fs.readFileSync(path.join(siteSrc, 'ui-model.yml'), 'utf8')
+ )
}
const opts = { base: src, cwd: src }
return merge([
- vfs.src('img/**/*.{jpg,png,svg}', opts)
- .pipe(imagemin()),
+ vfs.src('img/**/*.{jpg,png,svg}', opts).pipe(imagemin()),
- vfs.src('js/+([0-9])-*.js', opts)
+ vfs
+ .src('js/+([0-9])-*.js', opts)
.pipe(uglify())
.pipe(concat('js/site.js')),
vfs.src('fonts/*.woff*(2)', opts),
- vfs.src('css/site.css', opts)
- .pipe(postcss(postcssPlugins)),
+ vfs.src('css/site.css', opts).pipe(postcss(postcssPlugins)),
vfs.src('helpers/*.js', opts),
vfs.src('layouts/*.hbs', opts),
vfs.src('partials/*.hbs', opts),
- ])
- .pipe(vfs.dest(dest))
+ ]).pipe(vfs.dest(dest))
}