-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmodule.js
45 lines (41 loc) · 1.22 KB
/
module.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// module.js
const { resolve, join } = require('path')
const { readdirSync } = require('fs')
export default function(moduleOptions) {
// get all options for the module
const options = {
...moduleOptions,
...this.options.customCounter
}
// expose the namespace / set a default
if (!options.namespace) options.namespace = 'customCounter'
const { namespace } = options
// add all of the initial plugins
const pluginsToSync = [
'components/index.js',
'store/index.js',
'plugins/index.js',
'debug.js',
'middleware/index.js'
]
for (const pathString of pluginsToSync) {
this.addPlugin({
src: resolve(__dirname, pathString),
fileName: join(namespace, pathString),
options
})
}
// sync all of the files and folders to revelant places in the nuxt build dir (.nuxt/)
const foldersToSync = ['plugins/helpers', 'store/modules', 'components/lib']
for (const pathString of foldersToSync) {
const path = resolve(__dirname, pathString)
for (const file of readdirSync(path)) {
this.addTemplate({
src: resolve(path, file),
fileName: join(namespace, pathString, file),
options
})
}
}
}
module.exports.meta = require('./package.json')