Skip to content

Commit

Permalink
Merge pull request #346 from wearebraid/feature/nuxt-module
Browse files Browse the repository at this point in the history
adds nuxt module to source files and build process
  • Loading branch information
justin-schroeder committed Mar 2, 2021
2 parents 96a9d5f + 35b6836 commit f39ef63
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 90 deletions.
21 changes: 21 additions & 0 deletions nuxt/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import fs from 'fs'
import path from 'path'

export default function nuxtVueFormulate (moduleOptions) {
let formulateOptions = Object.assign({}, this.options.formulate, moduleOptions)
let configPath = false
// check if we have a user-provided config path
// or if a config file exists in the default location
if (formulateOptions.configPath) {
configPath = formulateOptions.configPath
} else if (fs.existsSync(`${this.options.srcDir}/formulate.config.js`)) {
configPath = '~/formulate.config.js'
}
// add the parsed config path back into the options object
formulateOptions = Object.assign({}, formulateOptions, { configPath })
// Register `plugin.js` template
this.addPlugin({
src: path.resolve(__dirname, 'plugin.js'),
options: formulateOptions
})
}
9 changes: 9 additions & 0 deletions nuxt/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Vue from 'vue'
import VueFormulate from '@braid/vue-formulate'
<% if (options.configPath) { %>
import options from '<%= options.configPath %>'
<% } else { %>
const options = {}
<% } %>

Vue.use(VueFormulate, options)
193 changes: 103 additions & 90 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f39ef63

Please sign in to comment.