Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 54a1981

Browse files
committed
vue-cli 3.0 配置文件
1 parent f82836a commit 54a1981

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

‎README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
### [document](https://github.com/kitorv/study-notes/blob/master/vue/VUE-01.md)
1010

11-
## vue-cli3.0 环境搭建
11+
## vue-cli 3.0 环境配置
1212

13-
### [vue-cli3.0](https://github.com/kitorv/vue-md-doc)
13+
### [vue.config.js](src/vue.config.js)
1414

1515
## Overview
1616

‎src/vue.config.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
module.exports = {
2+
// 配置【vue-markdown-loader】解析md格式的文件
3+
chainWebpack: config => {
4+
config.module
5+
.rule("md")
6+
.test(/\.md/)
7+
.use("vue-loader")
8+
.loader("vue-loader")
9+
.end()
10+
.use("vue-markdown-loader")
11+
.loader("vue-markdown-loader/lib/markdown-compiler")
12+
.options({
13+
raw: true,
14+
preventExtract: true,
15+
use: [
16+
[
17+
require("markdown-it-container"),
18+
"example-code",
19+
{
20+
validate: function(params) {
21+
return params.trim().match(/^demo\s+(.*)$/)
22+
},
23+
render(tokens, index) {
24+
let { nesting, info } = tokens[index]
25+
if (nesting === 1) {
26+
// 1.获取代码块的描述内容
27+
let content = info.trim().match(/^demo\s+(.*)$/) || []
28+
let description = content.length > 1 ? content[1] : ""
29+
var md = require("markdown-it")()
30+
if (description) {
31+
description = md.render(description)
32+
}
33+
// 2.获取代码块内的html和js代码
34+
let code = tokens[index + 1].content
35+
// 3.代码块包裹
36+
return `
37+
<k-example-code>
38+
<div class="source" slot="source">${code}</div>
39+
${description}
40+
<div class="highlight" slot="code">`
41+
} else {
42+
return `
43+
</div>
44+
</k-example-code>\n`
45+
}
46+
}
47+
}
48+
]
49+
]
50+
})
51+
}
52+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /