From 4652707705b3277d0341a945bff00960b3d905cc Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@iotlink.com>
Date: 星期二, 27 十月 2020 14:00:51 +0800
Subject: [PATCH] release V1.1.0 修改webpack,分离了chunkjs到各个应用

---
 vue.config.js     |   30 +++++++
 public/index.html |  167 +++++++++++++++++++++++++++--------------
 appPack.js        |    5 +
 package.json      |    2 
 4 files changed, 145 insertions(+), 59 deletions(-)

diff --git a/appPack.js b/appPack.js
index 5f0bda3..3ae79f0 100644
--- a/appPack.js
+++ b/appPack.js
@@ -79,4 +79,7 @@
     copyDirectory("dist/view/" + app, baseDir + "/" + app + "/view/" + app, copy)
     copyDirectory("dist/images/" + app, baseDir + "/" + app + "/images/" + app, copy)
   }
-})
\ No newline at end of file
+})
+
+// 绉诲姩element woff
+copyDirectory("dist/fonts/", "dist/css/fonts/", copy)
\ No newline at end of file
diff --git a/package.json b/package.json
index 711deae..c22fda4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "vue-smart-ai",
-  "version": "1.0.1",
+  "version": "1.1.0",
   "private": true,
   "scripts": {
     "serve": "vue-cli-service serve",
diff --git a/public/index.html b/public/index.html
index fac9533..798f7e1 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1,22 +1,17 @@
 <!DOCTYPE html>
 <html lang="en">
-  <head>
-    <meta charset="utf-8" />
-    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
-    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
-    <link
-      rel="icon"
-      type="image/png"
-      href="<%= BASE_URL %>favicon.png"
-      sizes="32x32"
-    />
-    <link rel="stylesheet" href="/fonts/alibaba/iconfont.css">
-    <link rel="stylesheet" href="/css/element-variables.scss">
-    <title><%= htmlWebpackPlugin.options.title %></title>
-    <style src="/css/common.scss" lang="scss"></style>
-    <style src="/css/overried.scss" lang="scss"></style>
-    <style >
-    html,body {
+
+<head>
+  <meta charset="utf-8" />
+  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
+  <meta name="viewport" content="width=device-width,initial-scale=1.0" />
+  <link rel="icon" type="image/png" href="<%= BASE_URL %>favicon.png" sizes="32x32" />
+  <link rel="stylesheet" href="/fonts/alibaba/iconfont.css">
+  <title><%= htmlWebpackPlugin.options.title %></title>
+
+  <style>
+    html,
+    body {
       font-family: "Avenir", Helvetica, Arial, sans-serif;
       -webkit-font-smoothing: antialiased;
       -moz-osx-font-smoothing: grayscale;
@@ -26,11 +21,13 @@
       height: 100%;
       font-size: 12px;
     }
+
     .el-button--primary:hover,
     .el-button--primary:focus {
       background: #2249b4;
       border-color: #2249b4;
     }
+
     .el-button--warning:hover,
     .el-button--warning:focus {
       background: #fd780b;
@@ -46,6 +43,7 @@
     .el-button--info {
       color: #222222;
     }
+
     .el-button--info:hover,
     .el-button--info:focus {
       background: rgb(190, 190, 190);
@@ -62,11 +60,13 @@
       border-color: #e9e9eb;
       color: #909399;
     }
+
     /* reset */
     html {
       color: #000;
       background: #fff;
     }
+
     body,
     div,
     dl,
@@ -91,48 +91,61 @@
       margin: 0;
       padding: 0;
     }
+
     /* body {
       font: 12px/1 Tahoma, Helvetica, Arial, "\5b8b\4f53", sans-serif;
     } */
     img {
       border: none;
     }
+
     em,
     strong {
       font-style: normal;
       font-weight: normal;
     }
+
     li {
       list-style: none;
     }
+
     table {
       border-collapse: collapse;
       border-spacing: 0;
     }
+
     h1 {
       font-size: 18px;
     }
+
     h2 {
       font-size: 16px;
     }
+
     h3 {
       font-size: 14px;
     }
+
     h4,
     h5,
     h6 {
       font-size: 100%;
     }
+
     q:before,
     q:after {
       content: "";
-    } /* 娑堥櫎q鍓嶅悗鐨勫唴瀹� */
+    }
+
+    /* 娑堥櫎q鍓嶅悗鐨勫唴瀹� */
     button,
     input,
     select,
     textarea {
       font-size: 100%;
-    } /* 浣垮緱琛ㄥ崟鍏冪礌鍦� ie 涓嬭兘缁ф壙瀛椾綋澶у皬 */
+    }
+
+    /* 浣垮緱琛ㄥ崟鍏冪礌鍦� ie 涓嬭兘缁ф壙瀛椾綋澶у皬 */
     input,
     button,
     textarea,
@@ -144,26 +157,32 @@
       font-style: inherit;
       font-weight: inherit;
     }
+
     address,
     cite,
     dfn,
     em,
     var {
       font-style: normal;
-    } /* 灏嗘枩浣撴壎姝� */
+    }
+
+    /* 灏嗘枩浣撴壎姝� */
     /* link */
     a {
       color: #3d68e1;
       text-decoration: none;
     }
+
     a:hover {
       color: #2249b4;
       text-decoration: underline;
     }
+
     .fade-enter-active,
     .fade-leave-active {
       transition: opacity 0.5s;
     }
+
     .fade-enter,
     .fade-leave-active {
       opacity: 0;
@@ -189,16 +208,24 @@
       box-shadow: inset 0 0 3px rgba(245, 243, 243, 0.3);
       background-color: rgba(160, 158, 158, 0.8);
     }
+
     .fade-enter-active,
     .fade-leave-active {
       transition: opacity 0.5s;
     }
-    .fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
+
+    .fade-enter,
+    .fade-leave-to
+
+    /* .fade-leave-active below version 2.1.8 */
+      {
       opacity: 0;
     }
+
     .window {
       z-index: 10 !important;
     }
+
     .el-card__body {
       box-sizing: border-box;
     }
@@ -206,7 +233,7 @@
     .is-dark {
       background: #00000090 !important;
     }
-  
+
     .el-tooltip__popper {
       border-radius: 0px;
       padding: 5px 10px;
@@ -215,24 +242,31 @@
     .atooltip.el-tooltip__popper[x-placement^="bottom"] .popper__arrow {
       border-bottom-color: #20202090;
     }
+
     .atooltip.el-tooltip__popper[x-placement^="bottom"] .popper__arrow:after {
       border-bottom-color: #68666690;
     }
+
     .atooltip.el-tooltip__popper[x-placement^="top"] .popper__arrow {
       border-top-color: #20202090;
     }
+
     .atooltip.el-tooltip__popper[x-placement^="top"] .popper__arrow:after {
       border-top-color: #68666690;
     }
+
     .atooltip.el-tooltip__popper[x-placement^="left"] .popper__arrow {
       border-left-color: #20202090;
     }
+
     .atooltip.el-tooltip__popper[x-placement^="left"] .popper__arrow:after {
       border-left-color: #68666690;
     }
+
     .atooltip.el-tooltip__popper[x-placement^="right"] .popper__arrow {
       border-right-color: #20202090;
     }
+
     .atooltip.el-tooltip__popper[x-placement^="right"] .popper__arrow:after {
       border-right-color: #68666690;
     }
@@ -241,11 +275,14 @@
       overflow-y: hidden;
       overflow-x: hidden;
     }
+
     .el-menu-vertical-demo::-webkit-scrollbar {
       /*婊氬姩鏉℃暣浣撴牱寮�*/
-      width: 4px; /*楂樺鍒嗗埆瀵瑰簲妯珫婊氬姩鏉$殑灏哄*/
+      width: 4px;
+      /*楂樺鍒嗗埆瀵瑰簲妯珫婊氬姩鏉$殑灏哄*/
       height: 4px;
     }
+
     .el-menu-vertical-demo::-webkit-scrollbar-thumb {
       /*婊氬姩鏉¢噷闈㈠皬鏂瑰潡*/
       border-radius: 5px;
@@ -253,6 +290,7 @@
       -webkit-box-shadow: inset 0 0 5px rgba(157, 165, 183, 0);
       background: rgb(202, 201, 201);
     }
+
     .el-menu-vertical-demo::-webkit-scrollbar-track {
       /*婊氬姩鏉¢噷闈㈣建閬�*/
       box-shadow: inset 0 0 5px rgba(157, 165, 183, 0);
@@ -260,9 +298,11 @@
       border-radius: 0;
       background: rgb(255, 255, 255);
     }
+
     .el-menu-vertical-demo::-webkit-scrollbar-thumb:hover {
       background: rgba(0, 0, 0, 0.4);
     }
+
     .el-menu-vertical-demo:hover {
       overflow-y: visible;
       overflow-x: hidden;
@@ -285,14 +325,16 @@
       border-radius: 2px;
     }
 
-    .el-message-box .el-message-box__btns .el-button--primary{
-      background-color:#3d68e1;
-      border-color:#3d68e1;
+    .el-message-box .el-message-box__btns .el-button--primary {
+      background-color: #3d68e1;
+      border-color: #3d68e1;
     }
-    .el-message-box .el-message-box__btns .el-button--primary:hover{
-      background-color:#2249b4;
-      border-color:#2249b4;
+
+    .el-message-box .el-message-box__btns .el-button--primary:hover {
+      background-color: #2249b4;
+      border-color: #2249b4;
     }
+
     .btn-icon {
       cursor: pointer;
     }
@@ -301,36 +343,45 @@
       filter: drop-shadow(0 0 0 #fff);
       opacity: 0.8;
     }
-    .clearfix::after{
+
+    .clearfix::after {
       content: '';
       display: block;
       height: 0;
       clear: both;
     }
+
     .mb10 {
       margin-bottom: 10px;
     }
+
     .mt15 {
       margin-top: 15px;
     }
+
     .pl20 {
       padding-left: 20px;
     }
-    .cursor-pointer{
+
+    .cursor-pointer {
       cursor: pointer;
     }
+
     /* .flex-box{
       display: flex;
     } */
     .el-button--primary {
       color: #FFFFFF;
-      background-color: #3D68E1!important;
-      border-color: #3D68E1!important;
+      background-color: #3D68E1 !important;
+      border-color: #3D68E1 !important;
     }
-    .el-button--primary:hover,.el-button--primary:focus {
-      background: #2249b4!important;
-      border-color: #2249b4!important;
+
+    .el-button--primary:hover,
+    .el-button--primary:focus {
+      background: #2249b4 !important;
+      border-color: #2249b4 !important;
     }
+
     /* .el-input>input,.el-date-editor.el-input__inner{
       border-color: #dcdfe6!important;
     } */
@@ -344,41 +395,45 @@
       outline: none!important;
       border-color: #3D68E1!important;
     } */
-    .el-select-dropdown__list{
+    .el-select-dropdown__list {
       text-align: left;
     }
-    .el-form-item.is-required:not(.is-no-asterisk) > .el-form-item__label:before{
-      margin-left: -8px!important;
+
+    .el-form-item.is-required:not(.is-no-asterisk)>.el-form-item__label:before {
+      margin-left: -8px !important;
       margin-right: 0;
     }
-    .el-input.is-disabled .el-input__suffix{
+
+    .el-input.is-disabled .el-input__suffix {
       visibility: hidden;
     }
-    .form-tip{
+
+    .form-tip {
       color: #999;
       position: relative;
       text-align: left;
       padding-left: 10px;
     }
-    .form-tip:before{
-      content:'*';
+
+    .form-tip:before {
+      content: '*';
       position: absolute;
       top: 0;
       left: 0;
       color: #f90;
       font-size: 14px;
     }
-    </style>
+  </style>
 
-  </head>
-  <body>
-    <noscript>
-      <strong
-        >We're sorry but multiple-pages doesn't work properly without JavaScript
-        enabled. Please enable it to continue.</strong
-      >
-    </noscript>
-    <div id="app"></div>
-    <!-- built files will be auto injected -->
-  </body>
-</html>
+</head>
+
+<body>
+  <noscript>
+    <strong>We're sorry but multiple-pages doesn't work properly without JavaScript
+      enabled. Please enable it to continue.</strong>
+  </noscript>
+  <div id="app"></div>
+  <!-- built files will be auto injected -->
+</body>
+
+</html>
\ No newline at end of file
diff --git a/vue.config.js b/vue.config.js
index 92c74ea..0feb1d2 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -1,18 +1,39 @@
 'use strict'
 const glob = require('glob')
 const pages = {}
+const IS_VENDOR = /[\\/]node_modules[\\/]/
+const pageVendor = {}
 
 glob.sync('./src/pages/**/main.ts').forEach(path => {
   const chunk = path.split('./src/pages/')[1].split('/main.ts')[0]
+  const chunk_vendor = `${chunk}-vendors`
+  const chunk_common = `${chunk}-common`
   pages[chunk] = {
     entry: path,
     template: 'public/index.html',
     title: chunk == 'desktop/index' ? 'SmartAI' : chunk,
-    chunks: ['chunk-vendors', 'chunk-common', chunk]
+    chunks: [chunk_vendor, 'chunk-common', chunk]
   }
   if (chunk != 'index') {
     pages[chunk].filename = 'view/' + chunk + '.html'
   }
+
+  pageVendor[chunk_vendor] = {
+    name: chunk_vendor,
+    priority: -11,
+    chunks: c => c.name === chunk,
+    test: /\.js$/,
+    enforce: true
+  }
+
+  // pageVendor[chunk_common] = {
+  //   name: chunk_common,
+  //   priority: -20,
+  //   chunks: 'initial',
+  //   minChunks: 2,
+  //   reuseExistingChunk: true,
+  //   enforce: true
+  // }
 })
 module.exports = {
   pages,
@@ -29,6 +50,13 @@
         }
       ])
     }
+
+    config.optimization.splitChunks({
+      cacheGroups: pageVendor
+    })
+
+    // config.module.rule('fonts').use('url-loader').loader('file-loader').options({ name: 'fonts/[name].[ext]', publicPath: '../' })
+
   },
   productionSourceMap: false,
   filenameHashing: false,

--
Gitblit v1.8.0