forked from NightCatSama/vue-slider-component
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
106 lines (102 loc) · 2.62 KB
/
vue.config.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
103
104
105
106
const container = require('markdown-it-container')
const anchor = require('markdown-it-anchor')
const uslug = require('uslug')
const createContainer = (name, defaultTitle = '') => {
return [
container,
name,
{
render(tokens, idx) {
const token = tokens[idx]
const info = token.info
.trim()
.slice(name.length)
.trim()
if (name === 'example') {
return `
<script>
import examples from '@/examples/${info.split(' ')[0]}.ts'
export default {
data () {
return {
...examples
}
}
}
</script>\n
`.trim()
} else if (token.nesting === 1) {
return `<div class="${name} custom-block"><p class="custom-block-title">${info ||
defaultTitle}</p>\n`
} else {
return `</div>\n`
}
},
},
]
}
module.exports = {
parallel: false,
publicPath:
process.env.NODE_ENV === 'production' && process.env.VUE_APP_BUILD_MODE !== 'package'
? '/vue-slider-component/'
: '/',
outputDir: process.env.VUE_APP_BUILD_MODE === 'package' ? 'dist' : 'docs',
chainWebpack: config => {
if (process.env.VUE_APP_BUILD_MODE !== 'package') {
config.resolve.alias.set('vue$', 'vue/dist/vue.common').set('~', __dirname)
config.module
.rule('vue')
.test(/\.vue/)
.use('vue-loader')
.loader('vue-loader')
.options({
compilerOptions: {
whitespace: 'preserve',
},
})
.end()
config.module
.rule('md')
.test(/\.md/)
.use('vue-loader')
.loader('vue-loader')
.end()
.use('vue-markdown-loader')
.loader('vue-markdown-loader/lib/markdown-compiler')
.options({
raw: true,
preventExtract: true,
wrapper: 'article',
use: [
createContainer('tip', 'TIP'),
createContainer('warning', 'WARNING'),
createContainer('danger', 'WARNING'),
createContainer('version'),
createContainer('example'),
[
anchor,
{
level: 2,
permalink: true,
permalinkSymbol: '#',
permalinkBefore: true,
slugify: s => uslug(s),
},
],
],
})
} else {
config.output.libraryExport('default')
config.externals({
vue: {
commonjs: 'vue',
commonjs2: 'vue',
root: 'Vue',
amd: 'vue',
},
})
}
},
css: { extract: !!process.env.NO_EXTRACT_CSS },
}