This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 214
/
index.js
62 lines (55 loc) · 1.67 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
const loaderMerge = require('@neutrinojs/loader-merge');
const web = require('@neutrinojs/web');
const merge = require('deepmerge');
const path = require('path');
const MODULES = path.join(__dirname, 'node_modules');
module.exports = (neutrino, options = {}) => {
neutrino.use(web, options);
const babelLoader = neutrino.config.module.rule('compile').use('babel');
const vueOptions = merge({
extractCss: options.extract !== false,
loaders: {
js: {
loader: babelLoader.get('loader'),
options: babelLoader.get('options')
}
}
}, options.vue || {});
neutrino.config.module
.rule('vue')
.test(neutrino.regexFromExtensions(['vue']))
.use('vue')
.loader(require.resolve('vue-loader'))
.options(vueOptions);
neutrino.config.when(neutrino.config.module.rules.has('lint'), () => {
neutrino.use(loaderMerge('lint', 'eslint'), {
baseConfig: {
extends: ['plugin:vue/base']
},
plugins: ['vue'],
parser: 'vue-eslint-parser',
parserOptions: {
parser: 'babel-eslint'
}
});
});
if (neutrino.config.plugins.has('stylelint')) {
neutrino.config
.plugin('stylelint')
.tap(([options, ...args]) => [
merge(options, {
files: ['**/*.vue'],
config: {
processors: [require.resolve('stylelint-processor-html')],
rules: {
// allows empty <style> in vue components
'no-empty-source': null
}
}
}),
...args
]);
}
neutrino.config.resolve.modules.add(MODULES);
neutrino.config.resolveLoader.modules.add(MODULES);
};