Skip to content

Commit f4e24f5

Browse files
committed
ci: 新增 build demo和build lib
1 parent c5dc023 commit f4e24f5

19 files changed

+592
-22024
lines changed

build/webpack.build.js

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
const path = require('path');
2+
const VueLoaderPlugin = require('vue-loader/lib/plugin');
3+
4+
module.exports = {
5+
mode: 'production',
6+
entry: {
7+
main: path.resolve(__dirname, '../src/index.js')
8+
},
9+
output: {
10+
filename: 'vue-lay.common.js',
11+
path: path.resolve(__dirname, '../lib'),
12+
chunkFilename: 'vue-lay.common.js',
13+
publicPath: '/'
14+
},
15+
devServer: {
16+
hot: true,
17+
port: 3000,
18+
contentBase: './dist'
19+
},
20+
resolve: {
21+
alias: {
22+
vue$: 'vue/dist/vue.runtime.esm.js',
23+
'@': path.resolve(__dirname, '../src')
24+
},
25+
extensions: [
26+
'.mjs',
27+
'.js',
28+
'.jsx',
29+
'.vue',
30+
'.json',
31+
'.wasm'
32+
]
33+
},
34+
module: {
35+
rules: [
36+
{
37+
test: /\.vue$/,
38+
use: [
39+
{
40+
loader: 'cache-loader'
41+
},
42+
{
43+
loader: 'thread-loader'
44+
},
45+
{
46+
loader: 'vue-loader',
47+
options: {
48+
compilerOptions: {
49+
preserveWhitespace: false
50+
}
51+
}
52+
}
53+
]
54+
},
55+
{
56+
test: /\.(js|jsx)$/,
57+
exclude: /node_modules/,
58+
use: [
59+
{
60+
loader: 'babel-loader'
61+
}
62+
]
63+
},
64+
{
65+
test: /\.css$/,
66+
use: [
67+
{
68+
loader: 'style-loader'
69+
},
70+
{
71+
loader: 'css-loader'
72+
}
73+
]
74+
},
75+
{
76+
test: /\.(jpe?g|png|gif|svg)$/i,
77+
use: [
78+
{
79+
loader: 'url-loader',
80+
options: {
81+
limit: 4096,
82+
fallback: {
83+
loader: 'file-loader',
84+
options: {
85+
name: 'img/[name].[hash:8].[ext]'
86+
}
87+
}
88+
}
89+
}
90+
]
91+
},
92+
{
93+
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/i,
94+
use: [
95+
{
96+
loader: 'url-loader',
97+
options: {
98+
limit: 4096,
99+
fallback: {
100+
loader: 'file-loader',
101+
options: {
102+
name: 'fonts/[name].[hash:8].[ext]'
103+
}
104+
}
105+
}
106+
}
107+
]
108+
}
109+
]
110+
},
111+
plugins: [
112+
new VueLoaderPlugin()
113+
]
114+
};

build/webpack.demo.js

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
const path = require('path');
2+
const HtmlWebpackPlugin = require('html-webpack-plugin');
3+
const webpack = require('webpack');
4+
const VueLoaderPlugin = require('vue-loader/lib/plugin');
5+
6+
const MarkdownItContainer = require('markdown-it-container');
7+
const MarkdownItCheckBox = require('markdown-it-task-checkbox');
8+
const MarkdownItDec = require('markdown-it-decorate');
9+
/**
10+
* 增加 hljs 的 classname
11+
*/
12+
const wrapCustomClass = function (render) {
13+
return function (...args) {
14+
return render(...args)
15+
.replace('<code class="', '<code class="hljs ')
16+
.replace('<code>', '<code class="hljs">');
17+
};
18+
};
19+
20+
const vueMarkdown = {
21+
raw: true,
22+
// 定义处理规则
23+
preprocess: function (MarkdownIt, source) {
24+
// 表格
25+
MarkdownIt.renderer.rules.table_open = function () {
26+
return '<table class="table">';
27+
};
28+
29+
// ```html``` 给这种样式加个class hljs
30+
MarkdownIt.renderer.rules.fence = wrapCustomClass(
31+
MarkdownIt.renderer.rules.fence
32+
);
33+
// ```code``` 给这种样式加个class code_inline
34+
const codeInline = MarkdownIt.renderer.rules.code_inline;
35+
MarkdownIt.renderer.rules.code_inline = function (...args) {
36+
args[0][args[1]].attrJoin('class', 'code_inline');
37+
return codeInline(...args);
38+
};
39+
return source;
40+
},
41+
use: [
42+
// 'markdown-it-container'的作用是自定义代码块
43+
[
44+
MarkdownItContainer,
45+
'demo',
46+
{
47+
validate: params => params.trim().match(/^demo\s*(.*)$/),
48+
render: function (tokens, idx) {
49+
if (tokens[idx].nesting === 1) {
50+
return `<demo-block>
51+
<div slot="highlight">`;
52+
}
53+
return '</div></demo-block>\n';
54+
}
55+
}
56+
],
57+
[require('markdown-it-container'), 'tip'],
58+
[require('markdown-it-container'), 'warning'],
59+
[
60+
MarkdownItCheckBox,
61+
{
62+
disabled: true
63+
}
64+
],
65+
[MarkdownItDec]
66+
]
67+
};
68+
69+
module.exports = {
70+
mode: 'production',
71+
entry: {
72+
main: path.resolve(__dirname, '../src/main.js')
73+
},
74+
output: {
75+
filename: 'js/[name].[hash:8].js',
76+
path: path.resolve(__dirname, '../dist'),
77+
chunkFilename: 'js/[name].[hash:8].js',
78+
publicPath: 'http://cdn.jskou.com/'
79+
},
80+
resolve: {
81+
alias: {
82+
vue$: 'vue/dist/vue.runtime.esm.js',
83+
'@': path.resolve(__dirname, '../src')
84+
},
85+
extensions: [
86+
'.mjs',
87+
'.js',
88+
'.jsx',
89+
'.vue',
90+
'.json',
91+
'.wasm'
92+
]
93+
},
94+
module: {
95+
rules: [
96+
{
97+
test: /\.md$/,
98+
use: [
99+
{
100+
loader: 'vue-loader',
101+
options: {
102+
compilerOptions: {
103+
preserveWhitespace: false
104+
}
105+
}
106+
},
107+
{
108+
loader: 'vue-markdown-loader/lib/markdown-compiler',
109+
options: vueMarkdown
110+
}
111+
]
112+
},
113+
{
114+
test: /\.vue$/,
115+
use: [
116+
{
117+
loader: 'cache-loader'
118+
},
119+
{
120+
loader: 'thread-loader'
121+
},
122+
{
123+
loader: 'vue-loader',
124+
options: {
125+
compilerOptions: {
126+
preserveWhitespace: false
127+
}
128+
}
129+
}
130+
]
131+
},
132+
{
133+
test: /\.(js|jsx)$/,
134+
exclude: /node_modules/,
135+
use: [
136+
{
137+
loader: 'babel-loader'
138+
}
139+
]
140+
},
141+
{
142+
test: /\.css$/,
143+
use: [
144+
{
145+
loader: 'style-loader'
146+
},
147+
{
148+
loader: 'css-loader'
149+
}
150+
]
151+
},
152+
{
153+
test: /\.(jpe?g|png|gif|svg)$/i,
154+
use: [
155+
{
156+
loader: 'url-loader',
157+
options: {
158+
limit: 4096,
159+
fallback: {
160+
loader: 'file-loader',
161+
options: {
162+
name: 'img/[name].[hash:8].[ext]'
163+
}
164+
}
165+
}
166+
}
167+
]
168+
},
169+
{
170+
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/i,
171+
use: [
172+
{
173+
loader: 'url-loader',
174+
options: {
175+
limit: 4096,
176+
fallback: {
177+
loader: 'file-loader',
178+
options: {
179+
name: 'fonts/[name].[hash:8].[ext]'
180+
}
181+
}
182+
}
183+
}
184+
]
185+
}
186+
]
187+
},
188+
plugins: [
189+
new VueLoaderPlugin(),
190+
new webpack.DefinePlugin({
191+
'process.env': {
192+
BASE_URL: JSON.stringify('/')
193+
}
194+
}),
195+
new HtmlWebpackPlugin({
196+
template: path.resolve(__dirname, '../public/index.html')
197+
})
198+
199+
]
200+
};

lib/demo.html

Lines changed: 0 additions & 8 deletions
This file was deleted.

lib/fonts/iconfont.0208023e.eot

-39.9 KB
Binary file not shown.

lib/fonts/iconfont.d8583a84.ttf

-39.7 KB
Binary file not shown.

lib/fonts/iconfont.e9caaa06.woff

-26.1 KB
Binary file not shown.

lib/img/icon-ext.ba81b24c.png

-5.77 KB
Binary file not shown.

lib/img/icon.551539f8.png

-11.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)