Skip to content

Commit f39ef63

Browse files
Merge pull request #346 from wearebraid/feature/nuxt-module
adds nuxt module to source files and build process
2 parents 96a9d5f + 35b6836 commit f39ef63

File tree

3 files changed

+133
-90
lines changed

3 files changed

+133
-90
lines changed

nuxt/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import fs from 'fs'
2+
import path from 'path'
3+
4+
export default function nuxtVueFormulate (moduleOptions) {
5+
let formulateOptions = Object.assign({}, this.options.formulate, moduleOptions)
6+
let configPath = false
7+
// check if we have a user-provided config path
8+
// or if a config file exists in the default location
9+
if (formulateOptions.configPath) {
10+
configPath = formulateOptions.configPath
11+
} else if (fs.existsSync(`${this.options.srcDir}/formulate.config.js`)) {
12+
configPath = '~/formulate.config.js'
13+
}
14+
// add the parsed config path back into the options object
15+
formulateOptions = Object.assign({}, formulateOptions, { configPath })
16+
// Register `plugin.js` template
17+
this.addPlugin({
18+
src: path.resolve(__dirname, 'plugin.js'),
19+
options: formulateOptions
20+
})
21+
}

nuxt/plugin.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Vue from 'vue'
2+
import VueFormulate from '@braid/vue-formulate'
3+
<% if (options.configPath) { %>
4+
import options from '<%= options.configPath %>'
5+
<% } else { %>
6+
const options = {}
7+
<% } %>
8+
9+
Vue.use(VueFormulate, options)

package-lock.json

Lines changed: 103 additions & 90 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)