Skip to content

Commit

Permalink
Revert "fix: create cache (#47)"
Browse files Browse the repository at this point in the history
This reverts commit 45cabae.
  • Loading branch information
Nicolas Pennec committed Mar 24, 2019
1 parent 0b94d29 commit 26b4a4f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/index.js
Expand Up @@ -27,8 +27,16 @@ module.exports = function module (moduleOptions) {
// sitemap-routes.json is written to dist dir on build mode
const jsonStaticRoutesPath = path.resolve(this.options.buildDir, path.join('dist', 'sitemap-routes.json'))

let staticRoutes = fs.readJsonSync(jsonStaticRoutesPath, { throws: false })
let cache = null

if (staticRoutes && !this.options.dev) {
// Create a cache for routes
cache = createCache(staticRoutes, options)
// Hydrate cache
cache.get('routes')
}

// Extend routes
this.extendRoutes(routes => {
// Get all static routes and ignore dynamic routes
Expand All @@ -42,13 +50,14 @@ module.exports = function module (moduleOptions) {
staticRoutes = staticRoutes.filter(route => minimatch.match(route))
})

if (!this.options.dev) {
if (this.options.dev) {
// Create a cache for routes
cache = createCache(staticRoutes, options)
} else {
// Save static routes
fs.ensureDirSync(path.resolve(this.options.buildDir, 'dist'))
fs.writeJsonSync(jsonStaticRoutesPath, staticRoutes)
}

// Create a cache for routes
cache = createCache(staticRoutes, options)
})

if (options.generate) {
Expand Down

0 comments on commit 26b4a4f

Please sign in to comment.