Merge pull request #2819 from overleaf/jpa-sk-improve-pug-precompile

[misc] improve pug precompile

GitOrigin-RevId: 2eaa9be3f04c2639ca3b2fce4b36f42972622124
This commit is contained in:
Simon Detheridge 2020-05-22 12:15:45 +01:00 committed by Copybot
parent 2a8e2efe62
commit 4c88a83332

View file

@ -5,12 +5,18 @@ const globby = require('globby')
// Generate list of view names from app/views // Generate list of view names from app/views
const viewList = globby const viewList = globby
.sync('**/*.pug', { .sync('app/views/**/*.pug', {
onlyFiles: true, onlyFiles: true,
concurrency: 1, concurrency: 1,
ignore: '**/_*.pug', ignore: '**/_*.pug'
cwd: 'app/views'
}) })
.concat(
globby.sync('modules/*/app/views/**/*.pug', {
onlyFiles: true,
concurrency: 1,
ignore: '**/_*.pug'
})
)
.map(x => { .map(x => {
return x.replace(/\.pug$/, '') // strip trailing .pug extension return x.replace(/\.pug$/, '') // strip trailing .pug extension
}) })
@ -25,7 +31,7 @@ module.exports = {
let failures = 0 let failures = 0
viewList.forEach(view => { viewList.forEach(view => {
try { try {
let filename = app.get('views') + '/' + view + '.pug' let filename = view + '.pug'
pug.compileFile(filename, { cache: true }) pug.compileFile(filename, { cache: true })
logger.log({ view }, 'compiled') logger.log({ view }, 'compiled')
success++ success++