[Doc] fix tree shaking when build site

This commit is contained in:
陈嘉涵 2019-06-21 15:53:28 +08:00
parent 8564a5b1f1
commit 6e93c93d46
3 changed files with 32 additions and 30 deletions

View File

@ -49,6 +49,7 @@ module.exports = {
}, },
{ {
test: /\.less$/, test: /\.less$/,
sideEffects: true,
use: [ use: [
'style-loader', 'style-loader',
'css-loader', 'css-loader',
@ -63,10 +64,7 @@ module.exports = {
}, },
{ {
test: /\.md$/, test: /\.md$/,
use: [ use: ['vue-loader', '@vant/markdown-loader']
'vue-loader',
'@vant/markdown-loader'
]
}, },
{ {
test: /\.(ttf|svg)$/, test: /\.(ttf|svg)$/,

View File

@ -3,7 +3,9 @@ import docConfig from './doc.config';
import DemoList from './components/DemoList'; import DemoList from './components/DemoList';
import DemoPages from './components/DemoPages'; import DemoPages from './components/DemoPages';
import { demoWrapper } from './demo-common'; import { demoWrapper } from './demo-common';
import './utils/iframe-router'; import { initIframeRouter } from './utils/iframe-router';
initIframeRouter();
const registerRoute = ({ mobile, componentMap }) => { const registerRoute = ({ mobile, componentMap }) => {
const route = [ const route = [

View File

@ -5,7 +5,8 @@
import { setLang } from './lang'; import { setLang } from './lang';
import { iframeReady, isMobile } from '.'; import { iframeReady, isMobile } from '.';
window.syncPath = function () { export function initIframeRouter() {
window.syncPath = function () {
const router = window.vueRouter; const router = window.vueRouter;
const isInIframe = window !== window.top; const isInIframe = window !== window.top;
const currentDir = router.history.current.path; const currentDir = router.history.current.path;
@ -26,9 +27,10 @@ window.syncPath = function () {
} else if (isInIframe) { } else if (isInIframe) {
window.top.changePath(lang, currentDir); window.top.changePath(lang, currentDir);
} }
}; };
window.changePath = function (lang, path = '') { window.changePath = function (lang, path = '') {
setLang(lang); setLang(lang);
window.vueRouter.replace(path); window.vueRouter.replace(path);
}; };
}