forked from nuxt-community/legacy-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·35 lines (28 loc) · 847 Bytes
/
index.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
const fs = require('fs-extra')
const path = require('path')
module.exports = function nuxtVendor (moduleOptions) {
if (Array.isArray(moduleOptions)) {
moduleOptions = {
vendor: moduleOptions
}
}
const vendorDir = path.resolve(this.options.srcDir, 'static', 'vendor')
const vendor = [].concat(this.options.vendor, moduleOptions.vendor)
.filter(v => v)
.map(v => ({
src: v.src || path.resolve(this.options.modulesDir, v),
dst: v.dst || path.resolve(vendorDir, v)
}))
.filter(v => fs.existsSync(v.src))
if (!vendor.length) {
return
}
// Ensure static/vendor directory exists
fs.ensureDirSync(vendorDir)
// Link vendors
vendor.forEach(({src, dst}) => {
fs.removeSync(dst)
fs.ensureSymlinkSync(src, dst, 'junction')
})
}
module.exports.meta = require('./package.json')