Browse Source

chore: vue/cli replace vite

richard1015 5 years ago
parent
commit
30f25646dc

+ 2 - 5
src/sites/mobile/index.html

@@ -8,9 +8,7 @@
       content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
       name="viewport"
     />
-    <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
-    <title><%= htmlWebpackPlugin.options.title %></title>
-    <!-- <title>NutUI - 移动端Vue组件库</title> -->
+    <title>NutUI - 移动端Vue组件库</title>
     <script src="https://h5.m.jd.com/babelDiy/Zeus/2846ykuM7PwipD9E2RzMj2BGEQpA/plugin/share.min.js"></script>
     <style>
       html {
@@ -31,8 +29,7 @@
       >
     </noscript>
     <div id="app"></div>
-
-    <!-- built files will be auto injected -->
+    <script type="module" src="./src//sites/mobile/main.ts"></script>
     <script>
       //分享配置
       var shareOption = {

+ 2 - 4
src/sites/doc/index.html

@@ -8,9 +8,7 @@
       content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
       name="viewport"
     />
-    <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
-    <title><%= htmlWebpackPlugin.options.title %></title>
-    <!-- <title>NutUI - 移动端Vue组件库</title> -->
+    <title>NutUI - 移动端Vue组件库</title>
     <script src="https://h5.m.jd.com/babelDiy/Zeus/2846ykuM7PwipD9E2RzMj2BGEQpA/plugin/share.min.js"></script>
     <style>
       html {
@@ -47,7 +45,7 @@
       >
     </noscript>
     <div id="doc"></div>
-    <!-- built files will be auto injected -->
+    <script type="module" src="./src//sites/doc/main.ts"></script>
     <script>
       //分享配置
       var shareOption = {

+ 15 - 34
package.json

@@ -18,6 +18,7 @@
     "webpack",
     "vue component",
     "vue3 component",
+    "vite",
     "jdc",
     "jdcfe"
   ],
@@ -35,35 +36,24 @@
     "CHANGELOG.md"
   ],
   "scripts": {
-    "dev": "vue-cli-service serve",
-    "serve": "vue-cli-service serve",
-    "build": "vue-cli-service build",
-    "lint": "vue-cli-service lint",
-    "upload": "vue-cli-service build && node ./jd/upload.js",
+    "dev": "vite",
+    "build": "vite build",
+    "serve": "vite preview",
+    "upload": "vite build && node ./jd/upload.js",
     "add": "node jd/createComponentMode.js"
   },
   "dependencies": {
-    "@types/swiper": "^5.4.1",
     "axios": "^0.21.0",
-    "core-js": "^3.6.5",
     "gsap": "^3.6.0",
-    "sass": "^1.27.0",
-    "sass-loader": "^10.0.4",
-    "swiper": "^4.0.2",
-    "vue": "^3.0.0",
-    "vue-router": "^4.0.0-rc.1"
+    "sass": "^1.32.8",
+    "vue": "^3.0.5",
+    "vue-router": "^4.0.4"
   },
   "devDependencies": {
     "@commitlint/cli": "^10.0.0",
     "@commitlint/config-conventional": "^10.0.0",
-    "@typescript-eslint/eslint-plugin": "^2.33.0",
-    "@typescript-eslint/parser": "^2.33.0",
-    "@vue/cli-plugin-babel": "~4.5.8",
-    "@vue/cli-plugin-eslint": "~4.5.8",
-    "@vue/cli-plugin-router": "~4.5.8",
-    "@vue/cli-plugin-typescript": "~4.5.8",
-    "@vue/cli-service": "~4.5.8",
-    "@vue/compiler-sfc": "^3.0.2",
+    "@vitejs/plugin-vue": "^1.1.4",
+    "@vue/compiler-sfc": "^3.0.5",
     "@vue/eslint-config-prettier": "^6.0.0",
     "@vue/eslint-config-typescript": "^5.0.2",
     "eslint": "^6.7.2",
@@ -73,16 +63,12 @@
     "highlight.js": "^10.3.1",
     "husky": "^4.3.0",
     "lint-staged": "^10.5.0",
-    "loader-utils": "^2.0.0",
-    "markdown-it": "^12.0.2",
-    "markdown-it-anchor": "^6.0.0",
-    "markdown-it-chain": "^1.3.0",
-    "markdown-it-container": "^3.0.0",
     "prettier": "^1.19.1",
+    "swiper": "4.0.2",
     "transliteration": "^2.2.0",
-    "typescript": "~3.9.3",
-    "vue-loader": "16.0.0-beta.7",
-    "vue-template-compiler": "^2.6.12"
+    "typescript": "^4.1.5",
+    "vite": "^2.0.2",
+    "vite-plugin-md": "^0.5.1"
   },
   "eslintConfig": {
     "root": true,
@@ -116,10 +102,5 @@
   "repository": {
     "type": "git",
     "url": "https://github.com/jdf2e/nutui.git"
-  },
-  "browserslist": [
-    "> 1%",
-    "last 2 versions",
-    "not dead"
-  ]
+  }
 }

+ 23 - 0
scripts/gen-nutui-main.ts

@@ -0,0 +1,23 @@
+/**
+ * 生成入口文件
+ */
+export class Gen {
+  constructor() {
+    this.init();
+  }
+
+  init() {
+    const template = `
+        import { App } from 'vue';
+        export default {
+            install(app: App<Element>): void {
+                const files = require.context('@/packages', true, /index\.vue$/);
+                files.keys().forEach(component => {
+                const componentEntity = files(component).default;
+                app.component(componentEntity.name, componentEntity);
+                });
+            }
+        };
+        `;
+  }
+}

+ 0 - 479
src/config.js

@@ -1,479 +0,0 @@
-module.exports = {
-  versions: [
-    {
-      name: '1.x',
-      link: '/1x/'
-    },
-    {
-      name: '2.x',
-      link: '/'
-    },
-    {
-      name: '3.x',
-      link: '/3x/'
-    }
-  ],
-  header: [
-    {
-      name: 'guide',
-      cName: '指南',
-      path: '/'
-    },
-    {
-      name: 'intro',
-      cName: '组件',
-      path: '/'
-    },
-    {
-      name: 'example',
-      cName: '示例',
-      path: '/'
-    },
-    {
-      name: 'resource',
-      cName: '资源',
-      path: '/resource'
-    }
-  ],
-  docs: {
-    name: '指南',
-    packages: [
-      {
-        name: 'intro',
-        cName: '介绍',
-        show: true
-      },
-      {
-        name: 'start',
-        cName: '快速上手',
-        show: true
-      },
-      {
-        name: 'theme',
-        cName: '主题定制',
-        show: true
-      },
-      {
-        name: 'international',
-        cName: '国际化',
-        show: true
-      },
-      {
-        name: 'https://github.com/jdf2e/nutui/releases',
-        cName: '更新日志',
-        show: true,
-        isLink: true
-      }
-    ]
-  },
-  nav: [
-    {
-      name: '布局组件',
-      packages: [
-        {
-          name: 'Button',
-          sort: 1,
-          cName: '按钮组件',
-          type: 'component',
-          show: true,
-          desc: '按钮用于触发一个操作,如提交表单。',
-          author: 'richard1015'
-        },
-        {
-          name: 'collapse',
-          sort: 2,
-          cName: '折叠面板',
-          type: 'component',
-          show: true,
-          desc: '折叠面板',
-          author: 'Ymm0008'
-        },
-        {
-          name: 'collapse',
-          sort: 3,
-          cName: '折叠面板-item',
-          type: 'component',
-          show: false,
-          desc: '折叠面板-item',
-          author: 'Ymm0008'
-        },
-        {
-          name: 'Layout',
-          sort: 4,
-          cName: '布局',
-          type: 'component',
-          show: true,
-          desc: '简便地创建布局',
-          author: 'undo'
-        },
-        {
-          name: 'col',
-          sort: 5,
-          cName: '布局-Col',
-          type: 'component',
-          show: false,
-          desc: '布局组件Col',
-          author: 'undo'
-        },
-        {
-          name: 'row',
-          sort: 6,
-          cName: '布局-Row',
-          type: 'component',
-          show: false,
-          desc: '布局组件Row',
-          author: 'undo'
-        }
-      ]
-    },
-    {
-      name: '操作反馈',
-      packages: [
-        {
-          name: 'BackTop',
-          sort: '1',
-          cName: '回到顶部',
-          type: 'component',
-          show: true,
-          desc: '较长页面快捷回到顶部',
-          author: 'liqiong43'
-        },
-        {
-          name: 'ActionSheet',
-          sort: '1',
-          cName: '动作面板',
-          type: 'component',
-          show: true,
-          desc: '底部弹出动作菜单面板',
-          author: 'zhangyufei'
-        },
-        {
-          name: 'Toast',
-          sort: '1',
-          cName: '吐司',
-          type: 'component',
-          show: true,
-          desc: '轻提示',
-          author: 'undo'
-        },
-        {
-          version: '3.0.0',
-          name: 'Notify',
-          type: 'component',
-          cName: '消息提示',
-          desc: '在页面顶部展示消息提示,支持函数调用和组件调用两种方式',
-          sort: 4,
-          show: true,
-          author: 'wangyue217'
-        },
-        {
-          version: '3.0.0',
-          name: 'Picker',
-          type: 'component',
-          cName: '选择器',
-          desc:
-            '提供多个选型集合供用户选择,支持单列选择和多列级联,通常与弹出层配合使用',
-          sort: 5,
-          show: true,
-          author: 'yangkaixuan'
-        }
-      ]
-    },
-    {
-      name: '基础组件',
-      packages: [
-        {
-          name: 'Temp',
-          sort: 1,
-          cName: '模板组件',
-          type: 'component',
-          show: true,
-          desc: '组件模板示例',
-          author: 'richard1015'
-        },
-        {
-          name: 'Cell',
-          sort: 1,
-          cName: '单元格组件',
-          type: 'component',
-          show: true,
-          desc: '展示列表',
-          author: 'richard1015'
-        },
-        {
-          name: 'Uploader',
-          sort: 2,
-          cName: '上传组件',
-          type: 'component',
-          show: true,
-          desc: '上传文件、图片',
-          author: 'richard1015'
-        },
-        {
-          name: 'Icon',
-          sort: 3,
-          cName: '图标组件',
-          type: 'component',
-          show: true,
-          desc: '图标',
-          author: 'richard1015'
-        },
-        {
-          name: 'Price',
-          sort: 4,
-          cName: '价格组件',
-          type: 'component',
-          show: true,
-          desc: '价格组件',
-          author: 'ailululu'
-        },
-        {
-          name: 'Checkbox',
-          sort: 5,
-          cName: '复选按钮',
-          type: 'component',
-          show: true,
-          desc: '复选按钮',
-          author: 'Ymm0008'
-        },
-        {
-          name: 'Swiper',
-          sort: 6,
-          cName: '轮播',
-          type: 'component',
-          show: true,
-          desc: '轮播',
-          author: 'ailululu'
-        },
-        {
-          name: 'Avatar',
-          sort: 7,
-          cName: '头像',
-          type: 'component',
-          show: true,
-          desc: '头像',
-          author: 'ailululu'
-        },
-        {
-          name: 'Popup',
-          sort: 8,
-          cName: '弹出层',
-          type: 'component',
-          show: true,
-          desc:
-            '弹出层容器,用于展示弹窗、信息提示等内容,支持多个弹出层叠加展示',
-          author: 'szg2008',
-          version: '3.0.0'
-        },
-        {
-          name: 'Dialog',
-          type: 'component',
-          cName: '对话框',
-          desc:
-            '模态对话框,在浮层中显示,引导用户进行相关操作,支持图片对话框。',
-          sort: 8,
-          show: true,
-          author: 'dsj'
-        },
-        {
-          version: '3.0.0',
-          name: 'Radio',
-          type: 'component',
-          cName: '单选按钮',
-          desc: '单选按钮',
-          sort: 9,
-          show: true,
-          author: 'Ymm0008'
-        },
-        {
-          version: '3.0.0',
-          name: 'RadioGroup',
-          type: 'component',
-          cName: '单选按钮组',
-          desc: '单选按钮组',
-          sort: 10,
-          show: false,
-          author: 'Ymm0008'
-        },
-        {
-          version: '3.0.0',
-          name: 'CheckboxGroup',
-          type: 'component',
-          cName: '多选按钮组',
-          desc: '多选按钮组',
-          sort: 11,
-          show: false,
-          author: 'Ymm0008'
-        },
-        {
-          version: '3.0.0',
-          name: 'OverLay',
-          type: 'component',
-          cName: '遮罩层',
-          desc: '创建一个遮罩层,通常用于阻止用户进行其他操作',
-          sort: 14,
-          show: true,
-          author: 'szg2008'
-        },
-        {
-          version: '3.0.0',
-          name: 'InfiniteLoading',
-          type: 'component',
-          cName: '滚动加载',
-          desc: '列表滚动到底部自动加载更多数据',
-          sort: 15,
-          show: true,
-          author: 'yangxiaolu'
-        },
-        {
-          version: '3.0.0',
-          name: 'Range',
-          type: 'component',
-          cName: '区间选择器',
-          desc: '滑动输入条,用于在给定的范围内选择一个值。',
-          sort: 16,
-          show: true,
-          author: 'Jerry'
-        },
-        {
-          name: 'PullRefresh',
-          type: 'component',
-          cName: '下拉刷新',
-          desc: '下拉刷新',
-          sort: 16,
-          show: true,
-          author: 'yangxiaolu3'
-        }
-      ]
-    },
-    {
-      name: '导航组件',
-      packages: [
-        {
-          name: 'Navbar',
-          sort: 3,
-          cName: '导航组件',
-          type: 'componment',
-          show: true,
-          desc: '导航组件',
-          author: 'liqiong43'
-        },
-        {
-          name: 'tab',
-          sort: 1,
-          cName: '标签组件',
-          type: 'component',
-          show: true,
-          desc: '标签组件',
-          author: 'zhenyulei'
-        },
-        {
-          name: 'menu',
-          sort: 2,
-          cName: '菜单组件',
-          type: 'component',
-          show: true,
-          desc: '下拉菜单组件',
-          author: 'vickyYE'
-        },
-        {
-          name: 'tabbar',
-          sort: 2,
-          cName: '标签栏组件',
-          type: 'component',
-          show: true,
-          desc: '标签栏组件',
-          author: 'Drjingfubo'
-        },
-        {
-          version: '3.0.0',
-          name: 'NoticeBar',
-          type: 'component',
-          cName: '公告栏',
-          desc: '用于循环播放展示一组消息通知',
-          sort: 5,
-          show: false,
-          author: 'wangyue92'
-        }
-      ]
-    },
-    {
-      name: '数据录入',
-      packages: [
-        {
-          name: 'InputNumber',
-          sort: 1,
-          cName: '数字输入框',
-          type: 'component',
-          show: true,
-          desc: '数字输入框组件',
-          author: 'szg2008'
-        },
-        {
-          name: 'Input',
-          sort: 2,
-          cName: '输入框',
-          type: 'component',
-          show: true,
-          desc: '输入框组件',
-          author: 'gxx158'
-        },
-        {
-          version: '3.0.0',
-          name: 'Switch',
-          type: 'component',
-          cName: '开关组件',
-          desc: '用来打开或关闭选项',
-          sort: 3,
-          show: true,
-          author: 'zongyue3'
-        },
-        {
-          version: '3.0.0',
-          name: 'Rate',
-          sort: 4,
-          cName: '评分',
-          type: 'component',
-          show: true,
-          desc: '评分组件',
-          author: 'undo'
-        },
-        {
-          version: '3.0.0',
-          name: 'Calendar',
-          type: 'component',
-          cName: '日历',
-          desc: '日历组件',
-          sort: 5,
-          show: true,
-          author: ''
-        },
-        {
-          version: '3.0.0',
-          name: 'ShortPassword',
-          type: 'component',
-          cName: '短密码',
-          desc: '短密码组件',
-          sort: 6,
-          show: true,
-          author: 'Drjingfubo'
-        }
-      ]
-    },
-    {
-      name: '业务组件',
-      packages: [
-        {
-          version: '3.0.0',
-          name: 'Address',
-          type: 'component',
-          cName: '地址组件',
-          desc: '地址组件',
-          sort: 1,
-          show: true,
-          author: 'yangxiaolu3'
-        }
-      ]
-    }
-  ]
-};

+ 476 - 0
src/config.json

@@ -0,0 +1,476 @@
+{
+  "versions": [
+    {
+      "name": "1.x",
+      "link": "/1x/"
+    },
+    {
+      "name": "2.x",
+      "link": "/"
+    },
+    {
+      "name": "3.x",
+      "link": "/3x/"
+    }
+  ],
+  "header": [
+    {
+      "name": "guide",
+      "cName": "指南",
+      "path": "/"
+    },
+    {
+      "name": "intro",
+      "cName": "组件",
+      "path": "/"
+    },
+    {
+      "name": "example",
+      "cName": "示例",
+      "path": "/"
+    },
+    {
+      "name": "resource",
+      "cName": "资源",
+      "path": "/resource"
+    }
+  ],
+  "docs": {
+    "name": "指南",
+    "packages": [
+      {
+        "name": "intro",
+        "cName": "介绍",
+        "show": true
+      },
+      {
+        "name": "start",
+        "cName": "快速上手",
+        "show": true
+      },
+      {
+        "name": "theme",
+        "cName": "主题定制",
+        "show": true
+      },
+      {
+        "name": "international",
+        "cName": "国际化",
+        "show": true
+      },
+      {
+        "name": "https://github.com/jdf2e/nutui/releases",
+        "cName": "更新日志",
+        "show": true,
+        "isLink": true
+      }
+    ]
+  },
+  "nav": [
+    {
+      "name": "布局组件",
+      "packages": [
+        {
+          "name": "Button",
+          "sort": 1,
+          "cName": "按钮组件",
+          "type": "component",
+          "show": true,
+          "desc": "按钮用于触发一个操作,如提交表单。",
+          "author": "richard1015"
+        },
+        {
+          "name": "collapse",
+          "sort": 2,
+          "cName": "折叠面板",
+          "type": "component",
+          "show": true,
+          "desc": "折叠面板",
+          "author": "Ymm0008"
+        },
+        {
+          "name": "collapse",
+          "sort": 3,
+          "cName": "折叠面板-item",
+          "type": "component",
+          "show": false,
+          "desc": "折叠面板-item",
+          "author": "Ymm0008"
+        },
+        {
+          "name": "Layout",
+          "sort": 4,
+          "cName": "布局",
+          "type": "component",
+          "show": true,
+          "desc": "简便地创建布局",
+          "author": "undo"
+        },
+        {
+          "name": "col",
+          "sort": 5,
+          "cName": "布局-Col",
+          "type": "component",
+          "show": false,
+          "desc": "布局组件Col",
+          "author": "undo"
+        },
+        {
+          "name": "row",
+          "sort": 6,
+          "cName": "布局-Row",
+          "type": "component",
+          "show": false,
+          "desc": "布局组件Row",
+          "author": "undo"
+        }
+      ]
+    },
+    {
+      "name": "操作反馈",
+      "packages": [
+        {
+          "name": "BackTop",
+          "sort": "1",
+          "cName": "回到顶部",
+          "type": "component",
+          "show": true,
+          "desc": "较长页面快捷回到顶部",
+          "author": "liqiong43"
+        },
+        {
+          "name": "ActionSheet",
+          "sort": "1",
+          "cName": "动作面板",
+          "type": "component",
+          "show": true,
+          "desc": "底部弹出动作菜单面板",
+          "author": "zhangyufei"
+        },
+        {
+          "name": "Toast",
+          "sort": "1",
+          "cName": "吐司",
+          "type": "component",
+          "show": true,
+          "desc": "轻提示",
+          "author": "undo"
+        },
+        {
+          "version": "3.0.0",
+          "name": "Notify",
+          "type": "component",
+          "cName": "消息提示",
+          "desc": "在页面顶部展示消息提示,支持函数调用和组件调用两种方式",
+          "sort": 4,
+          "show": true,
+          "author": "wangyue217"
+        },
+        {
+          "version": "3.0.0",
+          "name": "Picker",
+          "type": "component",
+          "cName": "选择器",
+          "desc": "提供多个选型集合供用户选择,支持单列选择和多列级联,通常与弹出层配合使用",
+          "sort": 5,
+          "show": true,
+          "author": "yangkaixuan"
+        }
+      ]
+    },
+    {
+      "name": "基础组件",
+      "packages": [
+        {
+          "name": "Temp",
+          "sort": 1,
+          "cName": "模板组件",
+          "type": "component",
+          "show": true,
+          "desc": "组件模板示例",
+          "author": "richard1015"
+        },
+        {
+          "name": "Cell",
+          "sort": 1,
+          "cName": "单元格组件",
+          "type": "component",
+          "show": true,
+          "desc": "展示列表",
+          "author": "richard1015"
+        },
+        {
+          "name": "Uploader",
+          "sort": 2,
+          "cName": "上传组件",
+          "type": "component",
+          "show": true,
+          "desc": "上传文件、图片",
+          "author": "richard1015"
+        },
+        {
+          "name": "Icon",
+          "sort": 3,
+          "cName": "图标组件",
+          "type": "component",
+          "show": true,
+          "desc": "图标",
+          "author": "richard1015"
+        },
+        {
+          "name": "Price",
+          "sort": 4,
+          "cName": "价格组件",
+          "type": "component",
+          "show": true,
+          "desc": "价格组件",
+          "author": "ailululu"
+        },
+        {
+          "name": "Checkbox",
+          "sort": 5,
+          "cName": "复选按钮",
+          "type": "component",
+          "show": true,
+          "desc": "复选按钮",
+          "author": "Ymm0008"
+        },
+        {
+          "name": "Swiper",
+          "sort": 6,
+          "cName": "轮播",
+          "type": "component",
+          "show": true,
+          "desc": "轮播",
+          "author": "ailululu"
+        },
+        {
+          "name": "Avatar",
+          "sort": 7,
+          "cName": "头像",
+          "type": "component",
+          "show": true,
+          "desc": "头像",
+          "author": "ailululu"
+        },
+        {
+          "name": "Popup",
+          "sort": 8,
+          "cName": "弹出层",
+          "type": "component",
+          "show": true,
+          "desc": "弹出层容器,用于展示弹窗、信息提示等内容,支持多个弹出层叠加展示",
+          "author": "szg2008",
+          "version": "3.0.0"
+        },
+        {
+          "name": "Dialog",
+          "type": "component",
+          "cName": "对话框",
+          "desc": "模态对话框,在浮层中显示,引导用户进行相关操作,支持图片对话框。",
+          "sort": 8,
+          "show": true,
+          "author": "dsj"
+        },
+        {
+          "version": "3.0.0",
+          "name": "Radio",
+          "type": "component",
+          "cName": "单选按钮",
+          "desc": "单选按钮",
+          "sort": 9,
+          "show": true,
+          "author": "Ymm0008"
+        },
+        {
+          "version": "3.0.0",
+          "name": "RadioGroup",
+          "type": "component",
+          "cName": "单选按钮组",
+          "desc": "单选按钮组",
+          "sort": 10,
+          "show": false,
+          "author": "Ymm0008"
+        },
+        {
+          "version": "3.0.0",
+          "name": "CheckboxGroup",
+          "type": "component",
+          "cName": "多选按钮组",
+          "desc": "多选按钮组",
+          "sort": 11,
+          "show": false,
+          "author": "Ymm0008"
+        },
+        {
+          "version": "3.0.0",
+          "name": "OverLay",
+          "type": "component",
+          "cName": "遮罩层",
+          "desc": "创建一个遮罩层,通常用于阻止用户进行其他操作",
+          "sort": 14,
+          "show": true,
+          "author": "szg2008"
+        },
+        {
+          "version": "3.0.0",
+          "name": "InfiniteLoading",
+          "type": "component",
+          "cName": "滚动加载",
+          "desc": "列表滚动到底部自动加载更多数据",
+          "sort": 15,
+          "show": true,
+          "author": "yangxiaolu"
+        },
+        {
+          "version": "3.0.0",
+          "name": "Range",
+          "type": "component",
+          "cName": "区间选择器",
+          "desc": "滑动输入条,用于在给定的范围内选择一个值。",
+          "sort": 16,
+          "show": true,
+          "author": "Jerry"
+        },
+        {
+          "name": "PullRefresh",
+          "type": "component",
+          "cName": "下拉刷新",
+          "desc": "下拉刷新",
+          "sort": 16,
+          "show": true,
+          "author": "yangxiaolu3"
+        }
+      ]
+    },
+    {
+      "name": "导航组件",
+      "packages": [
+        {
+          "name": "Navbar",
+          "sort": 3,
+          "cName": "导航组件",
+          "type": "componment",
+          "show": true,
+          "desc": "导航组件",
+          "author": "liqiong43"
+        },
+        {
+          "name": "tab",
+          "sort": 1,
+          "cName": "标签组件",
+          "type": "component",
+          "show": true,
+          "desc": "标签组件",
+          "author": "zhenyulei"
+        },
+        {
+          "name": "menu",
+          "sort": 2,
+          "cName": "菜单组件",
+          "type": "component",
+          "show": true,
+          "desc": "下拉菜单组件",
+          "author": "vickyYE"
+        },
+        {
+          "name": "tabbar",
+          "sort": 2,
+          "cName": "标签栏组件",
+          "type": "component",
+          "show": true,
+          "desc": "标签栏组件",
+          "author": "Drjingfubo"
+        },
+        {
+          "version": "3.0.0",
+          "name": "NoticeBar",
+          "type": "component",
+          "cName": "公告栏",
+          "desc": "用于循环播放展示一组消息通知",
+          "sort": 5,
+          "show": false,
+          "author": "wangyue92"
+        }
+      ]
+    },
+    {
+      "name": "数据录入",
+      "packages": [
+        {
+          "name": "InputNumber",
+          "sort": 1,
+          "cName": "数字输入框",
+          "type": "component",
+          "show": true,
+          "desc": "数字输入框组件",
+          "author": "szg2008"
+        },
+        {
+          "name": "Input",
+          "sort": 2,
+          "cName": "输入框",
+          "type": "component",
+          "show": true,
+          "desc": "输入框组件",
+          "author": "gxx158"
+        },
+        {
+          "version": "3.0.0",
+          "name": "Switch",
+          "type": "component",
+          "cName": "开关组件",
+          "desc": "用来打开或关闭选项",
+          "sort": 3,
+          "show": true,
+          "author": "zongyue3"
+        },
+        {
+          "version": "3.0.0",
+          "name": "Rate",
+          "sort": 4,
+          "cName": "评分",
+          "type": "component",
+          "show": true,
+          "desc": "评分组件",
+          "author": "undo"
+        },
+        {
+          "version": "3.0.0",
+          "name": "Calendar",
+          "type": "component",
+          "cName": "日历",
+          "desc": "日历组件",
+          "sort": 5,
+          "show": true,
+          "author": ""
+        },
+        {
+          "version": "3.0.0",
+          "name": "ShortPassword",
+          "type": "component",
+          "cName": "短密码",
+          "desc": "短密码组件",
+          "sort": 6,
+          "show": true,
+          "author": "Drjingfubo"
+        }
+      ]
+    },
+    {
+      "name": "业务组件",
+      "packages": [
+        {
+          "version": "3.0.0",
+          "name": "Address",
+          "type": "component",
+          "cName": "地址组件",
+          "desc": "地址组件",
+          "sort": 1,
+          "show": true,
+          "author": "yangxiaolu3"
+        }
+      ]
+    }
+  ]
+}

+ 15 - 5
src/nutui.ts

@@ -1,10 +1,20 @@
 import { App } from 'vue';
 export default {
-  install(app: App<Element>): void {
-    const files = require.context('@/packages', true, /index\.vue$/);
-    files.keys().forEach(component => {
-      const componentEntity = files(component).default;
+  async install(app: App<Element>): Promise<void> {
+    /** webpack */
+    // const files = require.context('@/packages', true, /index\.vue$/);
+    // files.keys().forEach(component => {
+    //   const componentEntity = files(component).default;
+    //   app.component(componentEntity.name, componentEntity);
+    // });
+
+    /** vite */
+    const modulesPage = import.meta.glob('/src/packages/**/index.vue');
+    for (const path in modulesPage) {
+      let name = (/packages\/(.*)\/index.vue/.exec(path) as any[])[1];
+      let res: any = await modulesPage[path]();
+      const componentEntity = res?.default;
       app.component(componentEntity.name, componentEntity);
-    });
+    }
   }
 };

+ 1 - 1
src/packages/toast/index.vue

@@ -25,7 +25,7 @@
   </Transition>
 </template>
 <script>
-import Icon from '../icon';
+import Icon from '@/packages/icon/index.vue';
 import { toRefs, toRef, reactive, computed, watch, onMounted } from 'vue';
 import { createComponent } from '@/utils/create';
 const { create } = createComponent('toast');

+ 2 - 6
src/sites/config/env.ts

@@ -1,6 +1,5 @@
 type EnvConfig = {
   baseUrl: string;
-  buildTime: number | string | undefined;
   isPrd: boolean;
 };
 
@@ -13,13 +12,10 @@ type EnvConfig = {
 
 const config: EnvConfig = {
   baseUrl: '',
-  buildTime: process.env.buildTime,
   isPrd: true // 是否为线上
 };
-
-console.log('NODE_ENV', process.env.NODE_ENV);
-
-switch (process.env.NODE_ENV) {
+let p = 'development';
+switch (p) {
   case 'development':
     /*
      * 开发环境    => npm run dev

+ 3 - 3
src/sites/doc/components/Header.vue

@@ -20,7 +20,7 @@
             </router-link>
           </li>
           <li class="nav-item" :class="{ active: isActive(header[2].name) }">
-            <a href="http://localhost:8080/demo.html#/">
+            <a href="demo.html#/">
               {{ header[2].cName }}
             </a>
           </li>
@@ -67,7 +67,7 @@
 <script lang="ts">
 import { defineComponent, reactive, computed, onMounted } from 'vue';
 import Search from './Search.vue';
-import { header } from '@/config';
+import { header } from '@/config.json';
 import { currentRoute, themeColor } from '@/sites/assets/util/ref';
 export default defineComponent({
   name: 'doc-header',
@@ -102,7 +102,7 @@ export default defineComponent({
     };
     const isActive = computed(() => {
       return function(name: string) {
-        console.log(name, currentRoute.value);
+        // console.log(name, currentRoute.value);
         // console.log('name1', currentRoute.value == name.toLowerCase());
         return currentRoute.value == name.toLowerCase();
       };

+ 1 - 1
src/sites/doc/components/Nav.vue

@@ -42,7 +42,7 @@
 <script lang="ts">
 import { defineComponent, reactive, computed, onMounted } from 'vue';
 import { currentRoute } from '@/sites/assets/util/ref';
-import { nav, docs } from '@/config';
+import { nav, docs } from '@/config.json';
 export default defineComponent({
   name: 'doc-nav',
   setup() {

+ 1 - 6
src/sites/doc/components/Search.vue

@@ -26,7 +26,7 @@
 </template>
 <script>
 import { defineComponent, reactive, onMounted, watch } from 'vue';
-import { nav } from '@/config.js';
+import { nav } from '@/config.json';
 export default defineComponent({
   name: 'search',
   setup() {
@@ -39,11 +39,6 @@ export default defineComponent({
       searchCName: ''
     });
     onMounted(() => {
-      const files = require.context('@/packages', true, /doc\.md$/);
-      // console.log(files)
-      files.keys().forEach(component => {
-        const componentEntity = files(component).default;
-      });
       // console.log('nav', nav);
       nav.forEach(item => {
         item.packages.forEach(value => {

+ 47 - 15
src/sites/doc/router.ts

@@ -5,32 +5,57 @@ import Resource from './views/Resource.vue';
 import Main from './views/Main.vue';
 import { HttpClient } from '../service/HttpClient';
 const pagesRouter: Array<RouteRecordRaw> = [];
-const files = require.context('@/packages', true, /doc\.md$/);
-files.keys().forEach(component => {
-  const componentEntity = files(component).default;
-  const name = `${component.split('/')[1]}`;
+
+/** webpack */
+// const files = require.context('@/packages', true, /doc\.md$/);
+// files.keys().forEach(component => {
+//   const componentEntity = files(component).default;
+//   const name = `${component.split('/')[1]}`;
+//   pagesRouter.push({
+//     path: '/' + name,
+//     component: componentEntity,
+//     name
+//   });
+// });
+
+/** vite */
+const modulesPage = import.meta.glob('/src/packages/**/doc.md');
+for (const path in modulesPage) {
+  let name = (/packages\/(.*)\/doc.md/.exec(path) as any[])[1];
   pagesRouter.push({
     path: '/' + name,
-    component: componentEntity,
+    component: modulesPage[path],
     name
   });
-});
-const docs = require.context('@/docs', true, /\.md$/);
-docs.keys().forEach(component => {
-  const componentEntity = docs(component).default;
-  const name = `${component.split('/')[1].replace('.md', '')}`;
+}
+
+/** webpack */
+// const docs = require.context('@/docs', true, /\.md$/);
+// docs.keys().forEach(component => {
+//   const componentEntity = docs(component).default;
+//   const name = `${component.split('/')[1].replace('.md', '')}`;
+//   pagesRouter.push({
+//     path: '/' + name,
+//     component: componentEntity,
+//     name
+//   });
+// });
+
+/** vite */
+const modulesDocs = import.meta.glob('/src/docs/*.md');
+for (const path in modulesDocs) {
+  let name = (/docs\/(.*).md/.exec(path) as any[])[1];
   pagesRouter.push({
     path: '/' + name,
-    component: componentEntity,
+    component: modulesDocs[path],
     name
   });
-});
+}
 
 const routes: Array<RouteRecordRaw> = [
-  { path: '/', redirect: '/main' },
   {
-    path: '/main',
-    name: 'main',
+    path: '/',
+    name: '/',
     component: Main
     // children: pagesRouter
   },
@@ -46,6 +71,13 @@ const routes: Array<RouteRecordRaw> = [
     component: Resource
   }
 ];
+routes.push({
+  name: 'notFound',
+  path: '/:path(.*)+',
+  redirect: {
+    name: '/'
+  }
+});
 const router = createRouter({
   history: createWebHashHistory(),
   routes,

+ 0 - 9
src/sites/doc/views/Main.vue

@@ -58,12 +58,6 @@
 </template>
 <script lang="ts">
 import { defineComponent, onMounted, reactive } from 'vue';
-import {
-  onBeforeRouteUpdate,
-  RouteLocationNormalized,
-  useRoute
-} from 'vue-router';
-import { currentRoute } from '@/sites/assets/util/ref';
 import Header from '@/sites/doc/components/Header.vue';
 import router from '../router';
 export default defineComponent({
@@ -72,9 +66,6 @@ export default defineComponent({
   setup() {
     const data = reactive({});
 
-    onMounted(() => {
-      const route = useRoute();
-    });
     function toIntro() {
       router.push({ path: '/intro' });
     }

+ 2 - 2
src/sites/mobile/components/Index.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="index">
     <div class="index-header">
-      <img src="@/sites/assets/images/logo-red.png" alt="" srcset="" />
+      <img src="../../assets/images/logo-red.png" alt="" srcset="" />
       <div class="info">
         <h1>Nut UI</h1>
         <p>一套京东风格的轻量级移动端 Vue 组件库</p>
@@ -29,7 +29,7 @@
 
 <script lang="ts">
 import { defineComponent, reactive } from 'vue';
-import { nav, versions } from '@/config';
+import { nav, versions } from '@/config.json';
 export default defineComponent({
   name: 'doc',
   components: {},

+ 0 - 1
src/sites/mobile/main.ts

@@ -4,7 +4,6 @@ import router from './router';
 import NutUI from '@/nutui';
 import '@/sites/assets/styles/reset.scss';
 import '@/utils/touchEmulator';
-
 createApp(App)
   .use(router)
   .use(NutUI)

+ 19 - 7
src/sites/mobile/router.ts

@@ -8,15 +8,27 @@ const routes: Array<RouteRecordRaw> = [
   }
 ];
 
-const files = require.context('@/packages', true, /demo\.vue$/);
-files.keys().forEach(component => {
-  const componentEntity = files(component).default;
+/** webpack */
+// const files = require.context('@/packages', true, /demo\.vue$/);
+// files.keys().forEach(component => {
+//   const componentEntity = files(component).default;
+//   routes.push({
+//     path: `/${componentEntity.baseName}`,
+//     name: componentEntity.baseName,
+//     component: componentEntity
+//   });
+// });
+
+/** vite */
+const modulesPage = import.meta.glob('/src/packages/**/demo.vue');
+for (const path in modulesPage) {
+  let name = (/packages\/(.*)\/demo.vue/.exec(path) as any[])[1];
   routes.push({
-    path: `/${componentEntity.baseName}`,
-    name: componentEntity.baseName,
-    component: componentEntity
+    path: '/' + name,
+    component: modulesPage[path],
+    name
   });
-});
+}
 
 routes.push({
   name: 'NotFound',

+ 9 - 21
tsconfig.json

@@ -2,30 +2,18 @@
   "compilerOptions": {
     "target": "esnext",
     "module": "esnext",
+    "moduleResolution": "node",
     "strict": true,
     "jsx": "preserve",
-    "importHelpers": true,
-    "moduleResolution": "node",
-    "skipLibCheck": true,
-    "esModuleInterop": true,
-    "allowSyntheticDefaultImports": true,
-    "resolveJsonModule": true,
     "sourceMap": true,
-    "noImplicitAny": false,
-    "baseUrl": ".",
-    "types": ["webpack-env"],
+    "resolveJsonModule": true,
+    "esModuleInterop": true,
+    "lib": ["esnext", "dom"],
+    "types": ["vite/client"],
     "paths": {
-      "@/*": ["src/*"]
-    },
-    "lib": ["esnext", "dom", "dom.iterable", "scripthost"]
+      "@/": ["./src"]
+    }
   },
-  "include": [
-    "src/**/*.ts",
-    "src/**/*.tsx",
-    "src/**/*.vue",
-    "tests/**/*.ts",
-    "tests/**/*.tsx",
-    "src/config.js"
-  ],
-  "exclude": ["node_modules"]
+  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
+  "exclude": ["./node_modules"]
 }

+ 43 - 0
vite.config.ts

@@ -0,0 +1,43 @@
+import { defineConfig } from 'vite';
+import vue from '@vitejs/plugin-vue';
+import Markdown from 'vite-plugin-md';
+import path from 'path';
+// https://vitejs.dev/config/
+export default defineConfig({
+  resolve: {
+    alias: [{ find: '@', replacement: path.resolve(__dirname, './src') }]
+  },
+  css: {
+    preprocessorOptions: {
+      scss: {
+        // example : additionalData: `@import "./src/design/styles/variables";`
+        // dont need include file extend .scss
+        additionalData: `@import "@/styles/variables.scss";@import "@/sites/assets/styles/variables.scss";`
+      }
+    }
+  },
+  plugins: [
+    vue({
+      include: [/\.vue$/, /\.md$/]
+    }),
+    Markdown()
+  ],
+  build: {
+    rollupOptions: {
+      // make sure to externalize deps that shouldn't be bundled
+      // into your library
+      // external: ['vue'],
+      // output: {
+      //   // Provide global variables to use in the UMD build
+      //   // for externalized deps
+      //   globals: {
+      //     vue: 'Vue'
+      //   }
+      // }
+    },
+    lib: {
+      entry: 'src/nutui.ts',
+      name: 'MyLib'
+    }
+  }
+});