-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
92 lines (88 loc) · 2.25 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
let deepmerge = require('deepmerge')
let babelMerge = require('babel-merge')
let babelLoader = require('@constgen/neutrino-babel-loader')
let { VueLoaderPlugin } = require('vue-loader')
let vueStyleLoader = require('./middlewares/vue-style-loader')
module.exports = function (customSettings = {}) {
return function (neutrino) {
let developmentMode = neutrino.config.get('mode') === 'development'
let productionMode = !developmentMode
let defaultSettings = {
babel : {},
polyfills: false,
browsers : customSettings.browsers ? undefined : ['defaults'],
node : undefined,
include : [],
exclude : []
}
let settings = deepmerge(defaultSettings, customSettings)
neutrino.use(
babelLoader({
test : /\.(j|t)s?$/,
include : settings.include,
exclude : settings.exclude,
polyfills: settings.polyfills,
targets : {
...(settings.browsers && { browsers: settings.browsers }),
...(settings.node && { node: settings.node })
},
babel: babelMerge(
{
presets: [
[require.resolve('@vue/babel-preset-jsx'), {
functional: true,
injectH : true,
vModel : true,
vOn : true
}]
]
},
settings.babel
)
})
)
neutrino.use(vueStyleLoader())
neutrino.config
.module
.rule('vue')
.test(/\.vue$/)
.include
.merge(settings.include || [])
.end()
.exclude
.merge(settings.exclude || [])
.end()
.use('vue')
.loader(require.resolve('vue-loader'))
.tap((options = {}) => deepmerge({
transformAssetUrls: {
img : 'src',
link : 'href',
video : ['src', 'poster'],
source: 'src',
audio : 'src',
image : ['xlink:href', 'href'],
use : ['xlink:href', 'href']
},
hotReload : developmentMode,
productionMode,
compilerOptions: {
whitespace: 'condense',
modules : false
},
prettify : false,
exposeFilename: developmentMode
}, options))
.end()
.end()
.end()
.plugin('vue')
.use(VueLoaderPlugin)
.end()
.resolve
.extensions
.merge(['.vue', '.js'])
.end()
.end()
}
}