Skip to content

Commit

Permalink
feat(nuxt-typed-vuex): automatically transpile module
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Aug 30, 2020
1 parent 0d8236b commit 35eb0a0
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 90 deletions.
10 changes: 0 additions & 10 deletions docs/content/en/getting-started-nuxt.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ position: 2

</alert>

3. You will need to transpile this module, by adding the following to your `nuxt.config`:

```ts{}[nuxt.config.js]
build: {
transpile: [
/typed-vuex/,
],
},
```

## Add type definitions

The module will inject a store accessor throughout your project (`$accessor`). It is not typed by default, so you will need to add types.
Expand Down
42 changes: 0 additions & 42 deletions examples/nuxt-ts/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,10 @@
import { Configuration } from '@nuxt/types'

const config: Configuration = {
mode: 'universal',
/*
** Headers of the page
*/
head: {
title: process.env.npm_package_name || '',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
hid: 'description',
name: 'description',
content: process.env.npm_package_description || '',
},
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
/*
** Global CSS
*/
css: [],
/*
** Plugins to load before mounting the App
*/
plugins: [],
/*
** Nuxt.js dev-modules
*/
buildModules: ['@nuxt/typescript-build', 'nuxt-typed-vuex'],
/*
** Nuxt.js modules
*/
modules: [],
/*
** Build configuration
*/
build: {
/*
** Transpile module (and plugin).
*/
transpile: [/typed-vuex/],
},
}

export default config
38 changes: 0 additions & 38 deletions examples/nuxt/nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,4 @@
export default {
mode: 'universal',
/*
** Headers of the page
*/
head: {
title: process.env.npm_package_name || '',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
hid: 'description',
name: 'description',
content: process.env.npm_package_description || '',
},
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
/*
** Global CSS
*/
css: [],
/*
** Plugins to load before mounting the App
*/
Expand All @@ -32,17 +7,4 @@ export default {
** Nuxt.js dev-modules
*/
buildModules: ['@nuxt/typescript-build', 'nuxt-typed-vuex'],
/*
** Nuxt.js modules
*/
modules: [],
/*
** Build configuration
*/
build: {
/*
** Transpile module (and plugin).
*/
transpile: [/typed-vuex/],
},
}
3 changes: 3 additions & 0 deletions packages/nuxt-typed-vuex/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const nuxtTypedVuex: Module = async function() {
store: normalize(path.join(buildDir, 'store')),
},
})

this.options.build.transpile = /* istanbul ignore next */ this.options.build.transpile || []
this.options.build.transpile.push(/typed-vuex/)
}

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

0 comments on commit 35eb0a0

Please sign in to comment.