forked from vuetifyjs/vue-cli-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
73 lines (63 loc) · 1.88 KB
/
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
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
// Imports
const { mergeRules } = require('./util/helpers')
module.exports = (api) => {
const dependencies = api.service.pkg.dependencies || {}
const devDependencies = api.service.pkg.devDependencies || {}
const hasVuetifyLoader = Boolean(
devDependencies['vuetify-loader'] ||
dependencies['vuetify-loader']
)
if (hasVuetifyLoader) {
const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin')
api.chainWebpack(config => {
config
.plugin('VuetifyLoaderPlugin')
.use(VuetifyLoaderPlugin)
})
}
// Resolve asset references from components
api.chainWebpack(config => {
config.module
.rule('vue')
.use('vue-loader')
.tap(options => ({
...options,
transformAssetUrls: {
// v-app-bar extends v-toolbar
'v-app-bar': 'src',
// v-carousel-item extends v-img
'v-carousel-item': ['src', 'lazy-src'],
'v-img': ['src', 'lazy-src'],
'v-navigation-drawer': 'src',
'v-parallax': 'src',
'v-toolbar': 'src',
},
}))
})
// Avoid loading styles in testing
if (process.env.NODE_ENV === 'test') {
api.chainWebpack(config => {
const sassRule = config.module.rule('sass')
sassRule.uses.clear()
sassRule.use('null-loader').loader('null-loader')
const scssRule = config.module.rule('scss')
scssRule.uses.clear()
scssRule.use('null-loader').loader('null-loader')
})
return
}
// Bootstrap SASS Variables
api.chainWebpack(config => {
['vue-modules', 'vue', 'normal-modules', 'normal'].forEach(match => {
for (let i = 0; i < 2; i++) {
const boolean = Boolean(i)
const rule = boolean ? 'sass' : 'scss'
config.module
.rule(rule)
.oneOf(match)
.use('sass-loader')
.tap(opt => mergeRules(api, opt, rule))
}
})
})
}