-
-
Notifications
You must be signed in to change notification settings - Fork 255
Conversation
try { | ||
fileConfig = require(_.cwd(configFilePath)) | ||
let resolvedConfigFilePath = _.cwd(configFilePath) | ||
if ( fs.existsSync(resolvedConfigFilePath) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have path-exists
installed, we can use that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never mind, I'll fix this
let resolvedConfigFilePath = _.cwd(configFilePath) | ||
if ( fs.existsSync(resolvedConfigFilePath) || | ||
fs.existsSync(resolvedConfigFilePath + '.js') || | ||
fs.existsSync(resolvedConfigFilePath + '.json') ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the configFilePath
may have extension, should stop adding extension if it already ends with .js
or .json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I see, we don't need to check this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damn, I accidentally clicked approved changes button 😐
fileConfig = require(_.cwd(configFilePath)) | ||
if (pathExists.sync(configFilePath) || | ||
pathExists.sync(configFilePath + '.js') || | ||
pathExists.sync(configFilePath + '.json')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can use something like:
const existingConfigFilePath = yield Promise
.all(['', '.js', '.json'].map(ext => pathExists(`${configFilePath}${ext}`)))
.then(result => getExistingFilePath(result))
fileConfig = require(existingConfigFilePath)
Could be faster?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if for just 3 sync calls, this async solution would be faster enough to justify that complexity.
If I create a vue.config.js like this:
It will fail to load config when webpack is not a dependency and vbuild is running globally as usual.
That's because it will raise a MODULE_NOT_FOUND error that is miss interpreted as config file not found, and nothing is printed.
This pull request try to fix that, but keep the default behavior to support .js and .json config files.
Please, let me know if I need to better explain myself