diff --git a/babel.config.js b/babel.config.js index fbaa638c..03a17be7 100644 --- a/babel.config.js +++ b/babel.config.js @@ -4,9 +4,8 @@ module.exports = { '@babel/preset-env', { loose: true, - modules: false - } - ] + modules: false, + }, + ], ], - plugins: ['@babel/plugin-syntax-dynamic-import'] }; diff --git a/build/webpack.doc.dev.js b/build/webpack.doc.dev.js deleted file mode 100644 index 1370fded..00000000 --- a/build/webpack.doc.dev.js +++ /dev/null @@ -1,81 +0,0 @@ -const path = require('path'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const ProgressBarPlugin = require('progress-bar-webpack-plugin'); -const { VueLoaderPlugin } = require('vue-loader'); - -module.exports = { - mode: 'development', - entry: { - 'vant-docs': './docs/src/index.js', - 'vant-preview': './docs/src/preview.js', - }, - output: { - path: path.join(__dirname, '../docs/dist'), - publicPath: '/', - chunkFilename: 'async_[name].js', - }, - stats: { - modules: false, - children: false, - }, - serve: { - open: true, - host: '0.0.0.0', - devMiddleware: { - logLevel: 'warn', - }, - hotClient: { - logLevel: 'warn', - allEntries: true, - }, - }, - resolve: { - extensions: ['.js', '.vue', '.css'], - }, - module: { - rules: [ - { - test: /\.vue$/, - use: [ - { - loader: 'vue-loader', - options: { - compilerOptions: { - preserveWhitespace: false, - }, - }, - }, - ], - }, - { - test: /\.js$/, - exclude: /node_modules/, - use: 'babel-loader', - }, - { - test: /\.(css|less)$/, - use: ['style-loader', 'css-loader', 'postcss-loader', 'less-loader'], - }, - { - test: /\.md$/, - use: ['vue-loader', '@vant/markdown-loader'], - }, - ], - }, - plugins: [ - new VueLoaderPlugin(), - new ProgressBarPlugin(), - new HtmlWebpackPlugin({ - chunks: ['vant-docs'], - template: 'docs/src/index.tpl', - filename: 'index.html', - inject: true, - }), - new HtmlWebpackPlugin({ - chunks: ['vant-preview'], - template: 'docs/src/index.tpl', - filename: 'preview.html', - inject: true, - }), - ], -}; diff --git a/build/webpack.doc.prd.js b/build/webpack.doc.prd.js deleted file mode 100644 index ae625e80..00000000 --- a/build/webpack.doc.prd.js +++ /dev/null @@ -1,14 +0,0 @@ -const path = require('path'); -const config = require('./webpack.doc.dev.js'); - -delete config.serve; - -module.exports = Object.assign(config, { - mode: 'production', - output: { - path: path.join(__dirname, '../docs/dist'), - publicPath: 'https://b.yzcdn.cn/vant-weapp/', - filename: '[name].[hash:8].js', - chunkFilename: 'async_[name].[chunkhash:8].js', - }, -}); diff --git a/docs/src/App.vue b/docs/src/App.vue deleted file mode 100644 index 6fc1fd65..00000000 --- a/docs/src/App.vue +++ /dev/null @@ -1,85 +0,0 @@ - - - - - diff --git a/docs/src/Preview.vue b/docs/src/Preview.vue deleted file mode 100644 index 264729c1..00000000 --- a/docs/src/Preview.vue +++ /dev/null @@ -1,99 +0,0 @@ - - - - - diff --git a/docs/src/doc.config.js b/docs/src/doc.config.js deleted file mode 100644 index 4fad680b..00000000 --- a/docs/src/doc.config.js +++ /dev/null @@ -1,74 +0,0 @@ -/* eslint-disable */ -import packageJson from '../../package.json'; -import components from '../../example/config'; -const { version } = packageJson; - -export const github = 'https://github.com/youzan/vant-weapp'; - -export const versions = [version, '0.x']; - -export default { - header: { - logo: { - image: 'https://img.yzcdn.cn/vant/logo.png', - title: 'Vant Weapp', - href: '#/', - }, - nav: { - logoLink: [ - { - image: 'https://img.yzcdn.cn/vant/vant-o.svg', - url: '/vant', - }, - { - image: 'https://img.yzcdn.cn/vant/logo/github.svg', - url: github, - }, - ], - }, - }, - nav: [ - { - name: '开发指南', - groups: [ - { - list: [ - { - path: '/intro', - title: '介绍', - md: true, - }, - { - path: '/quickstart', - title: '快速上手', - md: true, - }, - { - path: '/changelog', - title: '更新日志', - md: true, - }, - { - path: '/common', - title: '内置样式', - }, - { - path: '/custom-style', - title: '样式覆盖', - md: true, - }, - { - path: '/theme', - title: '定制主题', - md: true, - }, - ], - }, - ], - }, - { - name: '组件', - groups: components, - }, - ], -}; diff --git a/docs/src/index.js b/docs/src/index.js deleted file mode 100644 index 4a49448b..00000000 --- a/docs/src/index.js +++ /dev/null @@ -1,55 +0,0 @@ -import Vue from 'vue'; -import VueRouter from 'vue-router'; -import App from './App'; -import routes from './router'; -import VantDoc from '@vant/doc'; - -Vue.use(VueRouter).use(VantDoc); - -const router = new VueRouter({ - mode: 'hash', - routes: routes(), - scrollBehavior(to) { - if (to.hash) { - return { selector: to.hash }; - } - - return { x: 0, y: 0 }; - }, -}); - -const ua = navigator.userAgent.toLowerCase(); -const isMobile = /ios|iphone|ipod|ipad|android/.test(ua); - -router.beforeEach((route, redirect, next) => { - if (isMobile) { - location.replace('/vant/mobile.html?weapp=1'); - } - - next(); -}); - -router.afterEach(() => { - window.scrollTo(0, 0); -}); - -Vue.config.productionTip = false; - -new Vue({ - el: '#app', - mounted() { - setTimeout(() => { - // wait page init - if (this.$route.hash) { - const el = document.querySelector(this.$route.hash); - if (el) { - el.scrollIntoView({ - behavior: 'smooth', - }); - } - } - }, 1000); - }, - render: (h) => h(App), - router, -}); diff --git a/docs/src/preview.js b/docs/src/preview.js deleted file mode 100644 index fc14e942..00000000 --- a/docs/src/preview.js +++ /dev/null @@ -1,9 +0,0 @@ -import Vue from 'vue'; -import Preview from './Preview.vue'; - -Vue.config.productionTip = false; - -new Vue({ - el: '#app', - render: (h) => h(Preview), -}); diff --git a/docs/src/router.js b/docs/src/router.js deleted file mode 100644 index eecb7469..00000000 --- a/docs/src/router.js +++ /dev/null @@ -1,52 +0,0 @@ -import docConfig from './doc.config'; - -const registerRoute = () => { - const route = [ - { - path: '*', - redirect: () => `/intro`, - }, - ]; - - const navs = docConfig.nav || []; - - function addRoute(page) { - let { path } = page; - if (path) { - path = path.replace('/', ''); - - const component = () => - page.md - ? import(`../markdown/${path}.md`) - : import(`../../packages/${path}/README.md`); - - if (!component) { - return; - } - - route.push({ - name: '/' + path, - component, - path: `/${path}`, - meta: { - path, - name: page.title, - }, - }); - } - } - - navs.forEach((nav) => { - if (nav.groups) { - nav.groups.forEach((group) => { - group.list.forEach((page) => addRoute(page)); - }); - } else { - addRoute(nav); - } - }); - - return route; -}; - -export default registerRoute; diff --git a/package.json b/package.json index 218a261f..95820c71 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "gulp-rename": "^2.0.0", "miniprogram-api-typings": "^3.1.6", "miniprogram-ci": "^1.0.27", + "less": "^3.0.0", "tscpaths": "^0.0.9", "vue": "^3.0.0", "@vue/compiler-sfc": "^3.0.0" diff --git a/yarn.lock b/yarn.lock index bc55b2c1..c088f0f8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10264,6 +10264,22 @@ less-loader@^7.2.1: native-request "^1.0.5" source-map "~0.6.0" +less@^3.0.0: + version "3.13.1" + resolved "https://registry.npmjs.org/less/-/less-3.13.1.tgz#0ebc91d2a0e9c0c6735b83d496b0ab0583077909" + integrity sha512-SwA1aQXGUvp+P5XdZslUOhhLnClSLIjWvJhmd+Vgib5BFIr9lMNlQwmwUNOjXThF/A0x+MCYYPeWEfeWiLRnTw== + dependencies: + copy-anything "^2.0.1" + tslib "^1.10.0" + optionalDependencies: + errno "^0.1.1" + graceful-fs "^4.1.2" + image-size "~0.5.0" + make-dir "^2.1.0" + mime "^1.4.1" + native-request "^1.0.5" + source-map "~0.6.0" + less@^4.1.0: version "4.1.1" resolved "https://registry.npm.taobao.org/less/download/less-4.1.1.tgz?cache=0&sync_timestamp=1612065678706&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fless%2Fdownload%2Fless-4.1.1.tgz#15bf253a9939791dc690888c3ff424f3e6c7edba"