Skip to content

Commit 35eb0a0

Browse files
committed
feat(nuxt-typed-vuex): automatically transpile module
1 parent 0d8236b commit 35eb0a0

File tree

4 files changed

+3
-90
lines changed

4 files changed

+3
-90
lines changed

Diff for: docs/content/en/getting-started-nuxt.md

-10
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,6 @@ position: 2
4343

4444
</alert>
4545

46-
3. You will need to transpile this module, by adding the following to your `nuxt.config`:
47-
48-
```ts{}[nuxt.config.js]
49-
build: {
50-
transpile: [
51-
/typed-vuex/,
52-
],
53-
},
54-
```
55-
5646
## Add type definitions
5747

5848
The module will inject a store accessor throughout your project (`$accessor`). It is not typed by default, so you will need to add types.

Diff for: examples/nuxt-ts/nuxt.config.ts

-42
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,10 @@
11
import { Configuration } from '@nuxt/types'
22

33
const config: Configuration = {
4-
mode: 'universal',
5-
/*
6-
** Headers of the page
7-
*/
8-
head: {
9-
title: process.env.npm_package_name || '',
10-
meta: [
11-
{ charset: 'utf-8' },
12-
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
13-
{
14-
hid: 'description',
15-
name: 'description',
16-
content: process.env.npm_package_description || '',
17-
},
18-
],
19-
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
20-
},
21-
/*
22-
** Customize the progress-bar color
23-
*/
24-
loading: { color: '#fff' },
25-
/*
26-
** Global CSS
27-
*/
28-
css: [],
29-
/*
30-
** Plugins to load before mounting the App
31-
*/
32-
plugins: [],
334
/*
345
** Nuxt.js dev-modules
356
*/
367
buildModules: ['@nuxt/typescript-build', 'nuxt-typed-vuex'],
37-
/*
38-
** Nuxt.js modules
39-
*/
40-
modules: [],
41-
/*
42-
** Build configuration
43-
*/
44-
build: {
45-
/*
46-
** Transpile module (and plugin).
47-
*/
48-
transpile: [/typed-vuex/],
49-
},
508
}
519

5210
export default config

Diff for: examples/nuxt/nuxt.config.js

-38
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,4 @@
11
export default {
2-
mode: 'universal',
3-
/*
4-
** Headers of the page
5-
*/
6-
head: {
7-
title: process.env.npm_package_name || '',
8-
meta: [
9-
{ charset: 'utf-8' },
10-
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
11-
{
12-
hid: 'description',
13-
name: 'description',
14-
content: process.env.npm_package_description || '',
15-
},
16-
],
17-
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
18-
},
19-
/*
20-
** Customize the progress-bar color
21-
*/
22-
loading: { color: '#fff' },
23-
/*
24-
** Global CSS
25-
*/
26-
css: [],
272
/*
283
** Plugins to load before mounting the App
294
*/
@@ -32,17 +7,4 @@ export default {
327
** Nuxt.js dev-modules
338
*/
349
buildModules: ['@nuxt/typescript-build', 'nuxt-typed-vuex'],
35-
/*
36-
** Nuxt.js modules
37-
*/
38-
modules: [],
39-
/*
40-
** Build configuration
41-
*/
42-
build: {
43-
/*
44-
** Transpile module (and plugin).
45-
*/
46-
transpile: [/typed-vuex/],
47-
},
4810
}

Diff for: packages/nuxt-typed-vuex/src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const nuxtTypedVuex: Module = async function() {
1515
store: normalize(path.join(buildDir, 'store')),
1616
},
1717
})
18+
19+
this.options.build.transpile = /* istanbul ignore next */ this.options.build.transpile || []
20+
this.options.build.transpile.push(/typed-vuex/)
1821
}
1922

2023
;(nuxtTypedVuex as any).meta = { name: 'nuxt-typed-vuex' }

0 commit comments

Comments
 (0)