mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 01:54:48 +00:00
[Build] revert site to webpack config (#3747)
This commit is contained in:
41
docs/site/desktop/main.js
Normal file
41
docs/site/desktop/main.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import Vue from 'vue';
|
||||
import VueRouter from 'vue-router';
|
||||
import VantDoc from '@vant/doc';
|
||||
import App from './App';
|
||||
import routes from '../router';
|
||||
import { isMobile, importAll } from '../utils';
|
||||
|
||||
if (isMobile) {
|
||||
location.replace('mobile.html' + location.hash);
|
||||
}
|
||||
|
||||
Vue.use(VueRouter).use(VantDoc);
|
||||
|
||||
const docs = {};
|
||||
const docsFromMarkdown = require.context('../../markdown', false, /(en-US|zh-CN)\.md$/);
|
||||
const docsFromPackages = require.context('../../../src', true, /README(\.zh-CN)?\.md$/);
|
||||
|
||||
importAll(docs, docsFromMarkdown);
|
||||
importAll(docs, docsFromPackages);
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'hash',
|
||||
routes: routes({ componentMap: docs })
|
||||
});
|
||||
|
||||
router.afterEach(() => {
|
||||
window.scrollTo(0, 0);
|
||||
Vue.nextTick(() => window.syncPath());
|
||||
});
|
||||
|
||||
window.vueRouter = router;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Vue.config.productionTip = false;
|
||||
}
|
||||
|
||||
new Vue({
|
||||
el: '#app',
|
||||
render: h => h(App),
|
||||
router
|
||||
});
|
Reference in New Issue
Block a user