-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvusion.config.js
55 lines (54 loc) · 1.99 KB
/
vusion.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
const path = require('path');
const iterator = require('markdown-it-for-inline');
module.exports = {
type: 'app',
version: '>=0.6.0',
// lint: true,
clean: false,
extractCSS: true,
webpack: {
entry: {
bundle: ['babel-polyfill', './src/index.js'],
},
output: {
path: path.resolve(__dirname, './public'),
publicPath: '/public/',
},
resolve: {
alias: {
library$: path.resolve(process.cwd(), './src/library.js'),
},
},
module: {
rules: [{
test: /\.md$/,
use: [{
loader: 'vue-loader',
options: {
preserveWhitespace: false,
},
}, {
loader: '@vusion/md-vue-loader',
options: {
wrapper: 'u-article',
liveProcess(live, code) {
// 不好直接用自定义标签,容易出问题
return `<div class="u-example"><div>${live}</div><div slot="code"></div></div>\n\n${code}`;
},
postprocess(result) {
const re = /<div class="u-example"><div>([\s\S]+?)<\/div><div slot="code"><\/div><\/div>\s+(<pre[\s\S]+?<\/pre>)/g;
return result.replace(re, (m, live, code) => `<u-example><div>${live}</div><div slot="code">${code}</div></u-example>\n\n`);
},
plugins: [
[iterator, 'link_converter', 'link_open', (tokens, idx) => tokens[idx].tag = 'u-link'],
[iterator, 'link_converter', 'link_close', (tokens, idx) => tokens[idx].tag = 'u-link'],
],
},
}],
}],
},
},
webpackDevServer: {
contentBase: __dirname,
},
};