Merge pull request #2909 from liborvanek/dev

Include Vuex only when store is not empty
This commit is contained in:
Clark Du 2018-03-01 20:57:28 +08:00 committed by GitHub
commit f412827570
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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
}