-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuxt.js
74 lines (63 loc) · 1.78 KB
/
nuxt.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { join } from 'path'
import { setPublicDefaultOptions, requireOnce } from '@cloak-app/utils'
import { defaultsDeep } from 'lodash'
export default function() {
// Have Nuxt transpile resources
this.options.build.transpile.push('@cloak-app/visual')
// Allow components to be auto-imported by Nuxt
this.nuxt.hook('components:dirs', dirs => {
// Typical @cloak-app structure
dirs.push({
path: join(__dirname, './adapters/blocks'),
extensions: ['js', 'coffee'],
prefix: 'cloak-visual',
level: 2,
})
dirs.push({
path: join(__dirname, './components'),
extensions: ['vue', 'js', 'coffee'],
prefix: 'cloak-visual',
level: 2,
})
// Support shorter names for the global components, so we can use like
// `craft-visual` rather than `cloak-visual-craft`
dirs.push({
path: join(__dirname, './adapters/globals'),
extensions: ['js', 'coffee'],
level: 2,
})
})
// Set default @cloak-app/visual options
setPublicDefaultOptions(this, 'visual', {
placeholderColor: 'rgba(0,0,0,.2)',
srcsetSizes: [1920, 1440, 1024, 768, 425, 210],
blockMaxWidth: 'max-w',
})
// Make @nuxt/image best practice presets
defaultsDeep(this.options, {
image: {
presets: {
// See https://image.nuxtjs.org/providers/imgix#imgix-best-practices
imgix: {
modifiers: {
auto: 'format,compress',
crop: 'faces',
}
}
}
}
})
// Add @nuxt/image
requireOnce(this, '@nuxt/image')
// Expose @nuxt/image config options to helpers
defaultsDeep(this.options.publicRuntimeConfig, {
image: {
provider: this.options.image?.provider,
domains: this.options.image?.domains || [],
}
})
// Add helper methods
this.addPlugin(join(__dirname, 'plugins/helpers.js'))
}
// Required for published modules
module.exports.meta = require('./package.json')