Skip to content

Commit b3fc823

Browse files
committed
update advanced sfc docs
1 parent ad85cc2 commit b3fc823

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

docs/advanced/sfc.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ module.exports = {
7878
test: /\.vue$/,
7979
loader: 'vue-loader',
8080
},
81+
// for i18n resources (json/json5/yaml)
82+
{
83+
test: /\.(json5?|ya?ml)$/, // target json, json5, yaml and yml files
84+
type: 'javascript/auto',
85+
// Use `Rule.include` to specify the files of locale messages to be pre-compiled
86+
include: [
87+
path.resolve(__dirname, './src/locales'),
88+
],
89+
loader: '@intlify/vue-i18n-loader'
90+
}
91+
// for i18n custom block
8192
{
8293
resourceQuery: /blockType=i18n/,
8394
type: 'javascript/auto',
@@ -90,7 +101,6 @@ module.exports = {
90101
}
91102
```
92103

93-
94104
## Bundling with Rollup
95105

96106
### rollup-plugin-vue-i18n
@@ -301,13 +311,20 @@ In order to do that we have to create a `vue.config.js` at the root of our proje
301311
```js
302312
module.exports = {
303313
chainWebpack: config => {
314+
config.module
315+
.rule('i18n-resource')
316+
.test(/\.(json5?|ya?ml)$/)
317+
.include.add(path.resolve(__dirname, './src/locales'))
318+
.end()
319+
.type('javascript/auto')
320+
.use('i18n-resource')
321+
.loader('@intlify/vue-i18n-loader')
304322
config.module
305323
.rule('i18n')
306-
.resourceQuery(/blockType=i18n/)
307-
.type('javascript/auto')
308-
.use('i18n')
309-
.loader('@intlify/vue-i18n-loader')
310-
.end();
324+
.resourceQuery(/blockType=i18n/)
325+
.type('javascript/auto')
326+
.use('i18n')
327+
.loader('@intlify/vue-i18n-loader')
311328
}
312329
}
313330
```

0 commit comments

Comments
 (0)