Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Commit deb6f8e

Browse files
authored
feat: includeLocales option (#243)
1 parent 716d586 commit deb6f8e

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ module.exports = {
114114

115115
Whether to set up a birdge to migrate to `[email protected]` from `[email protected]`, Default `No` in prompt.
116116

117+
### `includeLocales`
118+
119+
- **Type:** `boolean`
120+
- **Default in prompt:** `false`
121+
- **Support project Vue version:** Vue 2 only
122+
123+
When `enableBridge` is `true`, i.e. in birdge mode, whether localization messags placed in `localeDir` option should be pre-compiled by message compiler or not.
124+
125+
If you use Composition API in bridge mode, this option must be `true` because all localization messages are bundled during production build.
126+
117127
### `runtimeOnly`
118128
- **Type:** `boolean`
119129
- **Default(No Prompt):** `false`

generator/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ module.exports = (api, options, rootOptions) => {
6868
if (enableBridge) {
6969
pkg.devDependencies['@intlify/vue-i18n-loader'] = '^3.2.0'
7070
pkg.dependencies['vue-i18n-bridge'] = '^9.2.0-beta.10'
71+
pkg.vue.pluginOptions.i18n['includeLocales'] = false
7172
}
7273
pkg.vue.pluginOptions.i18n['enableBridge'] = enableBridge
7374
}

index.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = (api, options) => {
99
runtimeOnly,
1010
enableLegacy,
1111
enableBridge,
12+
includeLocales,
1213
compositionOnly,
1314
fullInstall
1415
} = options.pluginOptions.i18n
@@ -86,15 +87,17 @@ module.exports = (api, options) => {
8687
.end()
8788
} else {
8889
// prettier-ignore
89-
webpackConfig.module
90-
.rule('i18n-resource')
91-
.test(/\.(json5?|ya?ml)$/)
92-
.include.add(path.resolve(__dirname, '../../', `./src/${localeDir}`))
93-
.end()
94-
.type('javascript/auto')
95-
.use('i18n-resource')
96-
.loader('@intlify/vue-i18n-loader')
97-
.options({ bridge: true })
90+
if (includeLocales) {
91+
webpackConfig.module
92+
.rule('i18n-resource')
93+
.test(/\.(json5?|ya?ml)$/)
94+
.include.add(path.resolve(__dirname, '../../', `./src/${localeDir}`))
95+
.end()
96+
.type('javascript/auto')
97+
.use('i18n-resource')
98+
.loader('@intlify/vue-i18n-loader')
99+
.options({ bridge: true })
100+
}
98101
// prettier-ignore
99102
webpackConfig.module
100103
.rule('i18n')

0 commit comments

Comments
 (0)