vue-cli-plugin-i18n should not rely on vue.config.js
idoub opened this issue · comments
Isaac Doub commented
Description of Problem
If vue-clie-plugin-i18n
is installed and you move all of your configuration to package.json, the following error is thrown when you run vue ui
.
(node:10494) UnhandledPromiseRejectionWarning: Error: Cannot find module '/apps/vue-sr-interview/vue.config'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at api.onPluginReload.project (/apps/vue-sr-interview/node_modules/vue-cli-plugin-i18n/ui.js:111:25)
at fns.forEach.fn (/Users/idoub/.nvm/versions/node/v10.15.3/lib/node_modules/@vue/cli/node_modules/@vue/cli-ui/apollo-server/connectors/
plugins.js:282:21)
at Array.forEach (<anonymous>)
at callHook (/Users/idoub/.nvm/versions/node/v10.15.3/lib/node_modules/@vue/cli/node_modules/@vue/cli-ui/apollo-server/connectors/plugin
s.js:282:7)
at Timeout.setTimeout [as _onTimeout] (/Users/idoub/.nvm/versions/node/v10.15.3/lib/node_modules/@vue/cli/node_modules/@vue/cli-ui/apoll
o-server/connectors/plugins.js:212:9)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:10494) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async func
tion without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:10494) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handl
ed will terminate the Node.js process with a non-zero exit code.
From the documentation, the "vue" field in package.json is valid configuration.
Steps to Reproduce
- Create a new simple vue-cli project.
- Open
vue ui
, install and configurevue-clie-plugin-i18n
. - Delete
vue.config.js
and add the following topackage.json
"vue": {
"i18n": {
"locale": "en",
"fallbackLocale": "en",
"localeDir": "locales",
"enableInSFC": false
}
}
- Restart
vue ui
and go to "Plugins". Error will print to console and page will fail to load.
Temporary Fix
Add a blank vue.config.js
file (it does not need any content).
Greg Veres commented
When I try to follow your directions, I get a different error:
" ERROR Invalid options in "vue" field in package.json: "i18n" is not allowed"
Ah, I see, i18n needs to be inside pluginOptions...
"vue": {
"pluginOptions": {
"i18n": {
"locale": "en",
"fallbackLocale": "en",
"localeDir": "locales",
"enableInSFC": false
}
}
}