mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-23 23:19:15 +08:00
load doc && demo in demand
This commit is contained in:
parent
4e57dfa797
commit
8ca524d9ac
4
.babelrc
4
.babelrc
@ -2,7 +2,9 @@
|
|||||||
"presets": [
|
"presets": [
|
||||||
[
|
[
|
||||||
"es2015",
|
"es2015",
|
||||||
{ "modules": false }
|
{
|
||||||
|
"modules": false
|
||||||
|
}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
@ -14,7 +14,6 @@ require('./genExamples')(isProduction);
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: {
|
entry: {
|
||||||
vendor: ['vue', 'vue-router', 'zan-doc'],
|
|
||||||
'vant-docs': './docs/src/index.js',
|
'vant-docs': './docs/src/index.js',
|
||||||
'vant-examples': './docs/src/examples.js'
|
'vant-examples': './docs/src/examples.js'
|
||||||
},
|
},
|
||||||
@ -22,7 +21,8 @@ module.exports = {
|
|||||||
path: path.join(__dirname, '../docs/dist'),
|
path: path.join(__dirname, '../docs/dist'),
|
||||||
publicPath: '/',
|
publicPath: '/',
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
umdNamedDefine: true
|
umdNamedDefine: true,
|
||||||
|
chunkFilename: 'async.[name].js'
|
||||||
},
|
},
|
||||||
devServer: {
|
devServer: {
|
||||||
historyApiFallback: {
|
historyApiFallback: {
|
||||||
@ -37,7 +37,7 @@ module.exports = {
|
|||||||
modules: [path.join(__dirname, '../node_modules'), 'node_modules'],
|
modules: [path.join(__dirname, '../node_modules'), 'node_modules'],
|
||||||
extensions: ['.js', '.vue', '.css'],
|
extensions: ['.js', '.vue', '.css'],
|
||||||
alias: {
|
alias: {
|
||||||
vue$: 'vue/dist/vue.esm.js',
|
vue: 'vue/dist/vue.esm.js',
|
||||||
src: path.join(__dirname, '../src'),
|
src: path.join(__dirname, '../src'),
|
||||||
packages: path.join(__dirname, '../packages'),
|
packages: path.join(__dirname, '../packages'),
|
||||||
lib: path.join(__dirname, '../lib'),
|
lib: path.join(__dirname, '../lib'),
|
||||||
@ -131,6 +131,10 @@ module.exports = {
|
|||||||
filename: 'examples.html',
|
filename: 'examples.html',
|
||||||
inject: true
|
inject: true
|
||||||
}),
|
}),
|
||||||
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
|
name: 'vendor',
|
||||||
|
minChunks: 2
|
||||||
|
}),
|
||||||
new webpack.HotModuleReplacementPlugin(),
|
new webpack.HotModuleReplacementPlugin(),
|
||||||
new OptimizeCssAssetsPlugin(),
|
new OptimizeCssAssetsPlugin(),
|
||||||
new ExtractTextPlugin({
|
new ExtractTextPlugin({
|
||||||
|
@ -8,7 +8,8 @@ module.exports = merge(devConfig, {
|
|||||||
path: path.join(__dirname, '../docs/dist'),
|
path: path.join(__dirname, '../docs/dist'),
|
||||||
publicPath: 'https://b.yzcdn.cn/zanui/vue',
|
publicPath: 'https://b.yzcdn.cn/zanui/vue',
|
||||||
filename: '[name].[hash:8].js',
|
filename: '[name].[hash:8].js',
|
||||||
umdNamedDefine: true
|
umdNamedDefine: true,
|
||||||
|
chunkFilename: 'async.[name].[chunkhash:8].js'
|
||||||
},
|
},
|
||||||
devtool: false,
|
devtool: false,
|
||||||
plugins: [
|
plugins: [
|
||||||
|
@ -30,6 +30,10 @@ module.exports = {
|
|||||||
"path": "/changelog",
|
"path": "/changelog",
|
||||||
"title": "更新日志",
|
"title": "更新日志",
|
||||||
noExample: true
|
noExample: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "业务组件",
|
||||||
|
"link": "/zanui/captain/component/quickstart"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,9 @@ import Vue from 'vue';
|
|||||||
import VueRouter from 'vue-router';
|
import VueRouter from 'vue-router';
|
||||||
import App from './ExamplesDocsApp';
|
import App from './ExamplesDocsApp';
|
||||||
import routes from './router.config';
|
import routes from './router.config';
|
||||||
import ZanUI from 'src/index.js';
|
|
||||||
import ZanDoc from 'zan-doc';
|
import ZanDoc from 'zan-doc';
|
||||||
import packageJson from '../../package.json';
|
|
||||||
import DemoBlock from './components/demo-block';
|
import DemoBlock from './components/demo-block';
|
||||||
|
|
||||||
const global = {
|
|
||||||
version: packageJson.version
|
|
||||||
};
|
|
||||||
window._global = global;
|
|
||||||
|
|
||||||
import '../assets/docs.css';
|
import '../assets/docs.css';
|
||||||
import 'packages/vant-css/src/index.css';
|
import 'packages/vant-css/src/index.css';
|
||||||
|
|
||||||
@ -22,11 +15,7 @@ function isMobile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vue.use(VueRouter);
|
Vue.use(VueRouter);
|
||||||
Vue.use(ZanUI);
|
|
||||||
Vue.use(ZanDoc);
|
Vue.use(ZanDoc);
|
||||||
Vue.use(ZanUI.Lazyload, {
|
|
||||||
lazyComponent: true
|
|
||||||
});
|
|
||||||
Vue.component('demo-block', DemoBlock);
|
Vue.component('demo-block', DemoBlock);
|
||||||
|
|
||||||
const routesConfig = routes();
|
const routesConfig = routes();
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
const navs = require('./doc.config')['zh-CN'].nav;
|
const navs = require('./doc.config')['zh-CN'].nav;
|
||||||
|
import componentDocs from '../examples-dist/entry-docs';
|
||||||
|
import componentDemos from '../examples-dist/entry-demos';
|
||||||
|
|
||||||
const registerRoute = (isExample) => {
|
const registerRoute = (isExample) => {
|
||||||
let route = [];
|
let route = [];
|
||||||
@ -9,30 +11,25 @@ const registerRoute = (isExample) => {
|
|||||||
|
|
||||||
if (nav.groups) {
|
if (nav.groups) {
|
||||||
nav.groups.forEach(group => {
|
nav.groups.forEach(group => {
|
||||||
group.list.forEach(nav => {
|
group.list.forEach(addRoute);
|
||||||
addRoute(nav);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
} else if (nav.children) {
|
} else if (nav.children) {
|
||||||
nav.children.forEach(nav => {
|
nav.children.forEach(addRoute);
|
||||||
addRoute(nav);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
addRoute(nav);
|
addRoute(nav);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function addRoute(page) {
|
function addRoute(page) {
|
||||||
const component = isExample
|
const { path } = page;
|
||||||
? require(`../examples-dist${page.path}.vue`)
|
if (path) {
|
||||||
: require(`../examples-docs${page.path}.md`);
|
const name = path.replace('/', '');
|
||||||
route.push({
|
route.push({
|
||||||
path: '/component' + page.path,
|
path: '/component' + path,
|
||||||
component: component.default || component
|
component: isExample ? componentDemos[name] : componentDocs[name]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// console.log(route);
|
|
||||||
|
|
||||||
return route;
|
return route;
|
||||||
};
|
};
|
||||||
|
14
package.json
14
package.json
@ -60,10 +60,10 @@
|
|||||||
"babel-polyfill": "^6.23.0",
|
"babel-polyfill": "^6.23.0",
|
||||||
"babel-preset-es2015": "^6.16.0",
|
"babel-preset-es2015": "^6.16.0",
|
||||||
"babel-runtime": "^6.25.0",
|
"babel-runtime": "^6.25.0",
|
||||||
"chai": "^4.1.0",
|
"chai": "^4.1.1",
|
||||||
"cheerio": "^0.22.0",
|
"cheerio": "^0.22.0",
|
||||||
"codecov": "^2.2.0",
|
"codecov": "^2.2.0",
|
||||||
"cross-env": "^5.0.1",
|
"cross-env": "^5.0.5",
|
||||||
"css-loader": "^0.28.4",
|
"css-loader": "^0.28.4",
|
||||||
"eslint-plugin-vue": "^2.1.0",
|
"eslint-plugin-vue": "^2.1.0",
|
||||||
"extract-text-webpack-plugin": "2.1.2",
|
"extract-text-webpack-plugin": "2.1.2",
|
||||||
@ -87,7 +87,7 @@
|
|||||||
"karma-spec-reporter": "^0.0.31",
|
"karma-spec-reporter": "^0.0.31",
|
||||||
"karma-webpack": "^2.0.4",
|
"karma-webpack": "^2.0.4",
|
||||||
"lerna": "^2.0.0",
|
"lerna": "^2.0.0",
|
||||||
"markdown-it": "^8.3.1",
|
"markdown-it": "^8.3.2",
|
||||||
"markdown-it-container": "^2.0.0",
|
"markdown-it-container": "^2.0.0",
|
||||||
"mocha": "^3.4.2",
|
"mocha": "^3.4.2",
|
||||||
"optimize-css-assets-webpack-plugin": "^3.0.0",
|
"optimize-css-assets-webpack-plugin": "^3.0.0",
|
||||||
@ -106,15 +106,15 @@
|
|||||||
"vue": "^2.4.2",
|
"vue": "^2.4.2",
|
||||||
"vue-hot-reload-api": "^2.1.0",
|
"vue-hot-reload-api": "^2.1.0",
|
||||||
"vue-html-loader": "^1.2.4",
|
"vue-html-loader": "^1.2.4",
|
||||||
"vue-loader": "^13.0.2",
|
"vue-loader": "^13.0.4",
|
||||||
"vue-markdown-loader": "^2.0.0",
|
"vue-markdown-loader": "^2.0.0",
|
||||||
"vue-router": "^2.7.0",
|
"vue-router": "^2.7.0",
|
||||||
"vue-style-loader": "^3.0.0",
|
"vue-style-loader": "^3.0.0",
|
||||||
"vue-template-compiler": "^2.4.2",
|
"vue-template-compiler": "^2.4.2",
|
||||||
"vue-template-es2015-compiler": "^1.5.3",
|
"vue-template-es2015-compiler": "^1.5.3",
|
||||||
"webpack": "^3.4.1",
|
"webpack": "^3.5.1",
|
||||||
"webpack-dev-server": "^2.6.1",
|
"webpack-dev-server": "^2.7.1",
|
||||||
"webpack-merge": "^4.1.0",
|
"webpack-merge": "^4.1.0",
|
||||||
"zan-doc": "^0.1.4"
|
"zan-doc": "0.1.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
49
yarn.lock
49
yarn.lock
@ -1147,9 +1147,9 @@ center-align@^0.1.1:
|
|||||||
align-text "^0.1.3"
|
align-text "^0.1.3"
|
||||||
lazy-cache "^1.0.3"
|
lazy-cache "^1.0.3"
|
||||||
|
|
||||||
chai@^4.1.0:
|
chai@^4.1.1:
|
||||||
version "4.1.0"
|
version "4.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/chai/-/chai-4.1.0.tgz#331a0391b55c3af8740ae9c3b7458bc1c3805e6d"
|
resolved "http://registry.npm.qima-inc.com/chai/download/chai-4.1.1.tgz#66e21279e6f3c6415ff8231878227900e2171b39"
|
||||||
dependencies:
|
dependencies:
|
||||||
assertion-error "^1.0.1"
|
assertion-error "^1.0.1"
|
||||||
check-error "^1.0.1"
|
check-error "^1.0.1"
|
||||||
@ -1787,9 +1787,9 @@ create-hmac@^1.1.0, create-hmac@^1.1.2:
|
|||||||
create-hash "^1.1.0"
|
create-hash "^1.1.0"
|
||||||
inherits "^2.0.1"
|
inherits "^2.0.1"
|
||||||
|
|
||||||
cross-env@^5.0.1:
|
cross-env@^5.0.5:
|
||||||
version "5.0.3"
|
version "5.0.5"
|
||||||
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.0.3.tgz#8f55acef7469fed364f4039a9f7ece90191e3981"
|
resolved "http://registry.npm.qima-inc.com/cross-env/download/cross-env-5.0.5.tgz#4383d364d9660873dd185b398af3bfef5efffef3"
|
||||||
dependencies:
|
dependencies:
|
||||||
cross-spawn "^5.1.0"
|
cross-spawn "^5.1.0"
|
||||||
is-windows "^1.0.0"
|
is-windows "^1.0.0"
|
||||||
@ -3854,7 +3854,7 @@ invert-kv@^1.0.0:
|
|||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6"
|
resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6"
|
||||||
|
|
||||||
ip@^1.1.0:
|
ip@^1.1.0, ip@^1.1.5:
|
||||||
version "1.1.5"
|
version "1.1.5"
|
||||||
resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a"
|
resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a"
|
||||||
|
|
||||||
@ -4856,6 +4856,16 @@ markdown-it@^8.3.1:
|
|||||||
mdurl "^1.0.1"
|
mdurl "^1.0.1"
|
||||||
uc.micro "^1.0.3"
|
uc.micro "^1.0.3"
|
||||||
|
|
||||||
|
markdown-it@^8.3.2:
|
||||||
|
version "8.3.2"
|
||||||
|
resolved "http://registry.npm.qima-inc.com/markdown-it/download/markdown-it-8.3.2.tgz#df4b86530d17c3bc9beec3b68d770b92ea17ae96"
|
||||||
|
dependencies:
|
||||||
|
argparse "^1.0.7"
|
||||||
|
entities "~1.1.1"
|
||||||
|
linkify-it "^2.0.0"
|
||||||
|
mdurl "^1.0.1"
|
||||||
|
uc.micro "^1.0.3"
|
||||||
|
|
||||||
math-expression-evaluator@^1.2.14:
|
math-expression-evaluator@^1.2.14:
|
||||||
version "1.2.16"
|
version "1.2.16"
|
||||||
resolved "https://registry.yarnpkg.com/math-expression-evaluator/-/math-expression-evaluator-1.2.16.tgz#b357fa1ca9faefb8e48d10c14ef2bcb2d9f0a7c9"
|
resolved "https://registry.yarnpkg.com/math-expression-evaluator/-/math-expression-evaluator-1.2.16.tgz#b357fa1ca9faefb8e48d10c14ef2bcb2d9f0a7c9"
|
||||||
@ -7693,9 +7703,9 @@ vue-lazyload@^1.0.6:
|
|||||||
version "1.0.6"
|
version "1.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/vue-lazyload/-/vue-lazyload-1.0.6.tgz#7d5494fc35c35fc84dcc271165b827e309b4e793"
|
resolved "https://registry.yarnpkg.com/vue-lazyload/-/vue-lazyload-1.0.6.tgz#7d5494fc35c35fc84dcc271165b827e309b4e793"
|
||||||
|
|
||||||
vue-loader@^13.0.2:
|
vue-loader@^13.0.4:
|
||||||
version "13.0.3"
|
version "13.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-13.0.3.tgz#b38d0fcd9818ae7b6a02932410d34943f9c9466d"
|
resolved "http://registry.npm.qima-inc.com/vue-loader/download/vue-loader-13.0.4.tgz#0a6d893698735fcf7037b20a23d724cb39eee7d4"
|
||||||
dependencies:
|
dependencies:
|
||||||
consolidate "^0.14.0"
|
consolidate "^0.14.0"
|
||||||
hash-sum "^1.0.2"
|
hash-sum "^1.0.2"
|
||||||
@ -7789,9 +7799,9 @@ webpack-dev-middleware@^1.11.0:
|
|||||||
range-parser "^1.0.3"
|
range-parser "^1.0.3"
|
||||||
time-stamp "^2.0.0"
|
time-stamp "^2.0.0"
|
||||||
|
|
||||||
webpack-dev-server@^2.6.1:
|
webpack-dev-server@^2.7.1:
|
||||||
version "2.6.1"
|
version "2.7.1"
|
||||||
resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-2.6.1.tgz#0b292a9da96daf80a65988f69f87b4166e5defe7"
|
resolved "http://registry.npm.qima-inc.com/webpack-dev-server/download/webpack-dev-server-2.7.1.tgz#21580f5a08cd065c71144cf6f61c345bca59a8b8"
|
||||||
dependencies:
|
dependencies:
|
||||||
ansi-html "0.0.7"
|
ansi-html "0.0.7"
|
||||||
bonjour "^3.5.0"
|
bonjour "^3.5.0"
|
||||||
@ -7803,6 +7813,7 @@ webpack-dev-server@^2.6.1:
|
|||||||
html-entities "^1.2.0"
|
html-entities "^1.2.0"
|
||||||
http-proxy-middleware "~0.17.4"
|
http-proxy-middleware "~0.17.4"
|
||||||
internal-ip "^1.2.0"
|
internal-ip "^1.2.0"
|
||||||
|
ip "^1.1.5"
|
||||||
loglevel "^1.4.1"
|
loglevel "^1.4.1"
|
||||||
opn "4.0.2"
|
opn "4.0.2"
|
||||||
portfinder "^1.0.9"
|
portfinder "^1.0.9"
|
||||||
@ -7829,9 +7840,9 @@ webpack-sources@^1.0.1:
|
|||||||
source-list-map "^2.0.0"
|
source-list-map "^2.0.0"
|
||||||
source-map "~0.5.3"
|
source-map "~0.5.3"
|
||||||
|
|
||||||
webpack@^3.4.1:
|
webpack@^3.5.1:
|
||||||
version "3.4.1"
|
version "3.5.1"
|
||||||
resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.4.1.tgz#4c3f4f3fb318155a4db0cb6a36ff05c5697418f4"
|
resolved "http://registry.npm.qima-inc.com/webpack/download/webpack-3.5.1.tgz#b749ee3d2b5a118dad53e8e41585b3f71e75499a"
|
||||||
dependencies:
|
dependencies:
|
||||||
acorn "^5.0.0"
|
acorn "^5.0.0"
|
||||||
acorn-dynamic-import "^2.0.0"
|
acorn-dynamic-import "^2.0.0"
|
||||||
@ -8057,9 +8068,9 @@ yeast@0.1.2:
|
|||||||
version "0.1.2"
|
version "0.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419"
|
resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419"
|
||||||
|
|
||||||
zan-doc@^0.1.4:
|
zan-doc@0.1.10:
|
||||||
version "0.1.8"
|
version "0.1.10"
|
||||||
resolved "https://registry.yarnpkg.com/zan-doc/-/zan-doc-0.1.8.tgz#e452f9afc29ff292106858f938a9604b82bb8120"
|
resolved "http://registry.npm.qima-inc.com/zan-doc/download/zan-doc-0.1.10.tgz#4a8b06d851315c2cd4092c9d770024c7a61b8099"
|
||||||
dependencies:
|
dependencies:
|
||||||
cheerio "0.22.0"
|
cheerio "0.22.0"
|
||||||
decamelize "^1.2.0"
|
decamelize "^1.2.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user