|
1 |
| -import type { Module } from '@nuxt/types' |
| 1 | +import { join, resolve } from 'upath' |
| 2 | + |
| 3 | +import type { Module, NuxtOptions } from '@nuxt/types' |
| 4 | + |
| 5 | +import { name, version } from '../package.json' |
2 | 6 |
|
3 | 7 | /**
|
4 | 8 | * @private
|
5 | 9 | */
|
6 | 10 | const nuxtTypedVuex: Module = async function() {
|
7 |
| - /* istanbul ignore if */ |
8 |
| - if (process.client || process.server) return |
| 11 | + const nuxtOptions = this.nuxt.options as NuxtOptions |
9 | 12 |
|
10 |
| - const { join, resolve }: typeof import('path') = process.client ? /* istanbul ignore next */ {} : require('path') |
11 |
| - const normalize: typeof import('normalize-path') = process.client ? /* istanbul ignore next */ {} : require('normalize-path') |
| 13 | + if (!nuxtOptions.store) console.warn('You do not have a store defined.') |
12 | 14 |
|
13 |
| - if (!this.options.store) console.warn('You do not have a store defined.') |
14 |
| - const buildDir = this.options.buildDir || '' |
15 | 15 | this.addPlugin({
|
16 | 16 | src: resolve(__dirname, '../template/plugin.js'),
|
17 | 17 | fileName: 'nuxt-typed-vuex.js',
|
18 | 18 | options: {
|
19 |
| - store: normalize(join(buildDir, 'store')), |
| 19 | + store: join(nuxtOptions.buildDir, 'store'), |
20 | 20 | },
|
21 | 21 | })
|
22 | 22 |
|
23 |
| - this.options.build = this.options.build || {} |
24 |
| - this.options.build.transpile = /* istanbul ignore next */ this.options.build.transpile || [] |
25 |
| - this.options.build.transpile.push(/typed-vuex/) |
| 23 | + nuxtOptions.build.transpile = /* istanbul ignore next */ nuxtOptions.build.transpile || [] |
| 24 | + nuxtOptions.build.transpile.push(/typed-vuex/) |
26 | 25 | }
|
27 | 26 |
|
28 |
| -;(nuxtTypedVuex as any).meta = { name: 'nuxt-typed-vuex' } |
29 |
| - |
30 |
| -export * from 'typed-vuex' |
| 27 | +;(nuxtTypedVuex as any).meta = { name, version } |
31 | 28 |
|
32 | 29 | export default nuxtTypedVuex
|
0 commit comments