forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.js
More file actions
52 lines (43 loc) · 1.2 KB
/
plugin.js
File metadata and controls
52 lines (43 loc) · 1.2 KB
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
import getConfig from './get-config'
import { jsTransform, jsTransformRegex } from './js-transform'
import { vueTransform, vueTransformRegex } from './vue-transform'
const defaultOptions = {
runMode: 'web-client',
autoImportComponentCase: 'kebab',
sassVariables: true
}
export default function (userOpts = {}) {
const opts = {
...defaultOptions,
...userOpts
}
const plugin = {
name: 'vite:quasar',
config (cfg) {
const vueCfg = cfg.plugins.find(entry => entry.name === 'vite:vue')
if (vueCfg === void 0) {
console.warn('In your Vite config file, please add the Quasar plugin after the Vue one')
process.exit(1)
}
return getConfig(opts, cfg)
}
}
if (opts.runMode !== 'ssr-server') {
plugin.transform = (src, id) => {
if (vueTransformRegex.test(id) === true) {
return {
code: vueTransform(src, opts.autoImportComponentCase),
map: null // provide source map if available
}
}
else if (jsTransformRegex.test(id) === true) {
return {
code: jsTransform(src),
map: null // provide source map if available
}
}
return null
}
}
return plugin
}