Doc: improve iframe load speed

This commit is contained in:
陈嘉涵
2017-09-04 13:01:58 +08:00
parent 8a951895f8
commit 225df48ba5
9 changed files with 83 additions and 43 deletions
+13 -19
View File
@@ -23,6 +23,7 @@ extractExample({
module.exports = {
entry: {
vendor: ['packages'],
'vant-docs': './docs/src/index.js',
'vant-examples': './docs/src/examples.js'
},
@@ -87,7 +88,18 @@ module.exports = {
},
{
test: /\.md/,
loader: 'vue-markdown-loader'
loader: 'vue-markdown-loader',
options: {
preventExtract: true,
use: [[require('markdown-it-container'), 'demo']],
preprocess(MarkdownIt, source) {
const styleRegexp = /<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/i;
const scriptRegexp = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/i;
MarkdownIt.renderer.rules.table_open = () =>
'<table class="zan-doc-table">';
return source.replace(styleRegexp, '').replace(scriptRegexp, '');
}
}
},
{
test: /\.(woff2?|eot|ttf|otf|svg)(\?.*)?$/,
@@ -98,23 +110,6 @@ module.exports = {
devtool: 'source-map',
plugins: [
new ProgressBarPlugin(),
new webpack.LoaderOptionsPlugin({
minimize: true,
options: {
vueMarkdown: {
preventExtract: true,
use: [
[require('markdown-it-container'), 'demo']
],
preprocess(MarkdownIt, source) {
const styleRegexp = /<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/i;
const scriptRegexp = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/i;
MarkdownIt.renderer.rules.table_open = () => '<table class="zan-doc-table">';
return source.replace(styleRegexp, '').replace(scriptRegexp, '');
}
}
}
}),
new HtmlWebpackPlugin({
chunks: ['vendor', 'vant-docs'],
template: 'docs/src/index.tpl',
@@ -132,7 +127,6 @@ module.exports = {
minChunks: 2,
filename: isProduction ? 'vendor.[hash:8].js' : 'vendor.js'
}),
new webpack.HotModuleReplacementPlugin(),
new OptimizeCssAssetsPlugin(),
new ExtractTextPlugin({
filename: isProduction ? '[name].[hash:8].css' : '[name].css',