-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.configs.js
102 lines (89 loc) · 2.84 KB
/
vue.configs.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
93
94
95
96
97
98
99
100
101
102
const path = require('path')
let analyzerPort = null
if (process.env.VUE_APP_MODE === 'development') {
const findFreePort = require('find-free-port-sync') // eslint-disable-line global-require
analyzerPort = findFreePort({
start: 8000,
end: 9000,
})
}
function addSlashInTheEndIfHasNo(str) {
return `${str.replace(/\/$/, '')}/`
}
module.exports.getAliases = function ({
dirname,
useLocalKit = false,
localKitPath = '',
assignAliases = {},
}) {
const aliases = {
Assets: path.resolve(dirname, 'src/assets/'),
Images: path.resolve(dirname, 'src/assets/images/'),
Styles: path.resolve(dirname, 'src/assets/styles/'),
Components: path.resolve(dirname, 'src/components/'),
Helpers: path.resolve(dirname, 'src/helpers/'),
Mixins: path.resolve(dirname, 'src/mixins/'),
Pages: path.resolve(dirname, 'src/pages/'),
Plugins: path.resolve(dirname, 'src/plugins/'),
Utils: path.resolve(dirname, 'src/utils/'),
}
if (useLocalKit && localKitPath === '') {
throw Error(`If getAliases() has { useLocalKit: true }, you should set 'localKitPath'\nFor example: getAliases({ useLocalKit: true, localKitPath: 'C:/Users/user/element-ui-kit/' })`)
}
let kitPath = useLocalKit ? localKitPath : 'node_modules/element-ui-kit/'
kitPath = addSlashInTheEndIfHasNo(kitPath)
Object.assign(aliases, {
KitComponents: path.resolve(`${kitPath}src/components/`),
KitDirectives: path.resolve(`${kitPath}src/directives/`),
KitIcons: path.resolve(`${kitPath}src/icons/`),
KitMixins: path.resolve(`${kitPath}src/mixins/`),
KitPlugins: path.resolve(`${kitPath}src/plugins/`),
KitStyles: path.resolve(`${kitPath}src/styles/`),
KitUtils: path.resolve(`${kitPath}src/utils/`),
})
Object.keys(assignAliases).forEach(alias => {
if (Object.hasOwnProperty.call(assignAliases, alias)) {
aliases[alias] = path.resolve(`${kitPath}${assignAliases[alias]}`)
}
})
return aliases
}
// npm i -D [email protected]
module.exports.rawLoader = function (config) {
config.module
.rule('raw-loader')
.test(/\.xml$/)
.use('raw-loader')
.loader('raw-loader')
.end()
}
// npm i -D [email protected] @kazupon/[email protected]
module.exports.i18nLoader = function (config) {
config.module
.rule('i18n')
.resourceQuery(/blockType=i18n/)
.type('javascript/auto')
.use('i18n')
.loader('@kazupon/vue-i18n-loader')
.end()
}
module.exports.vueConfig = {
transpileDependencies: [
'element-ui-kit',
],
configureWebpack: {
devServer: {
open: true,
},
devtool: process.env.VUE_APP_MODE === 'development' ? 'source-map' : 'nosources-source-map',
},
pluginOptions: {
webpackBundleAnalyzer: {
analyzerMode: 'disabled', // В 99,99% запусков сервера и билдов мы не используем analyzer, но если вдруг, то 'server', 'static'
openAnalyzer: false,
analyzerPort,
},
lintOnBuild: true,
lintStyleOnBuild: true,
},
}