Skip to content

Commit

Permalink
feat: Add option to automatically add vue-i18n-loader to Webpack config
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgv committed Aug 11, 2018
1 parent 3ca9981 commit d997b81
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
]
},
"dependencies": {
"@kazupon/vue-i18n-loader": "^0.3.0",
"acorn": "^5.6.2",
"cookie": "^0.3.1",
"esm": "3.0.28",
Expand Down
1 change: 1 addition & 0 deletions src/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const STRATEGIES = {
export const COMPONENT_OPTIONS_KEY = 'nuxtI18n'
export const DEFAULT_OPTIONS = {
vueI18n: {},
vueI18nLoader: false,
locales: [],
defaultLocale: null,
routesNameSeparator: '___',
Expand Down
8 changes: 8 additions & 0 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ export default function (userOptions) {
this.options.build.vendor.push('vue-i18n')
}

// Add vue-i18n-loader if applicable
if (options.vueI18nLoader) {
this.extendBuild(config => {
config.module.rules.find(el => el.loader === 'vue-loader')
.options.loaders.i18n = '@kazupon/vue-i18n-loader'
})
}

this.options.router.middleware.push('i18n')
this.options.render.bundleRenderer.directives = this.options.render.bundleRenderer.directives || {}
this.options.render.bundleRenderer.directives.t = i18nExtensions.directive
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,10 @@
version "1.4.0"
resolved "https://registry.yarnpkg.com/@csstools/convert-colors/-/convert-colors-1.4.0.tgz#ad495dc41b12e75d588c6db8b9834f08fa131eb7"

"@kazupon/vue-i18n-loader@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@kazupon/vue-i18n-loader/-/vue-i18n-loader-0.3.0.tgz#e068de2d75d891275814ae28ad1fcaf1b537694f"

"@mrmlnc/readdir-enhanced@^2.2.1":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"
Expand Down

0 comments on commit d997b81

Please sign in to comment.