Include Vuex only when store is not empty

This commit is contained in:
Libor Vaněk 2018-02-27 14:38:00 +01:00 committed by qm3ster
parent 0a823252ae
commit d7b1dd53ac
No known key found for this signature in database
GPG Key ID: D41763D409EF23A0

View File

@ -1,7 +1,7 @@
const _ = require('lodash')
const Debug = require('debug')
const { join, resolve } = require('path')
const { existsSync } = require('fs')
const { existsSync, readdirSync } = require('fs')
const { isUrl, isPureObject } = require('../common/utils')
const debug = Debug('nuxt:build')
@ -85,7 +85,12 @@ Options.from = function (_options) {
}
// If store defined, update store options to true unless explicitly disabled
if (options.store !== false && existsSync(join(options.srcDir, options.dir.store))) {
if (
options.store !== false &&
existsSync(join(options.srcDir, options.dir.store)) &&
readdirSync(join(options.srcDir, options.dir.store))
.find(filename => filename !== 'README.md' && filename[0] !== '.')
) {
options.store = true
}