From 2266f6d823fa9b455a967413a9840d76ee4b8ca2 Mon Sep 17 00:00:00 2001 From: zyy <1787816799@qq.com> Date: Wed, 13 Nov 2019 09:06:57 +0800 Subject: [PATCH] =?UTF-8?q?desc:=20=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 +-- public/index.html | 7 ++++ src/ibp/ibpPan.js | 2 +- src/main.js | 5 +-- src/router/index.js | 5 +-- src/settings.js | 10 +++--- src/store/index.js | 4 +-- vue.config.js | 81 ++++++++++++++++++++++++++++++++++----------- 8 files changed, 82 insertions(+), 36 deletions(-) diff --git a/package.json b/package.json index 720676fb8..03294a685 100644 --- a/package.json +++ b/package.json @@ -30,11 +30,8 @@ "stompjs": "^2.3.3", "storejs": "^1.0.25", "three": "^0.107.0", - "vue": "2.6.10", "vue-i18n": "^8.12.0", - "vue-router": "3.0.6", "vuedraggable": "^2.20.0", - "vuex": "3.1.0", "xlsx": "^0.14.2", "zrender": "^4.0.4" }, @@ -54,6 +51,7 @@ "babel-preset-env": "1.6.1", "babel-preset-stage-2": "6.24.1", "chalk": "2.4.2", + "compression-webpack-plugin": "^3.0.0", "connect": "3.6.6", "copy-webpack-plugin": "^4.5.2", "eslint": "5.15.3", diff --git a/public/index.html b/public/index.html index 8a86dbf8a..f98e3c574 100644 --- a/public/index.html +++ b/public/index.html @@ -6,10 +6,17 @@ + <%= webpackConfig.name %> + + + + + + diff --git a/src/ibp/ibpPan.js b/src/ibp/ibpPan.js index 06720a0f6..29e89b9dd 100644 --- a/src/ibp/ibpPan.js +++ b/src/ibp/ibpPan.js @@ -1,5 +1,5 @@ import zrender from 'zrender'; -import * as zrUtil from 'zrender/src/core/util'; +// import * as zrUtil from 'zrender/src/core/util'; import localStore from 'storejs'; import Options from './options'; import MouseController from './mouseController'; diff --git a/src/main.js b/src/main.js index a9c2bdb8c..438e917d2 100644 --- a/src/main.js +++ b/src/main.js @@ -3,24 +3,21 @@ import Vue from 'vue'; import 'normalize.css/normalize.css'; // A modern alternative to CSS resets import ElementUI from 'element-ui'; -// import ELEMENT from 'element-ui'; import ElementLocale from 'element-ui/lib/locale'; import 'element-ui/lib/theme-chalk/index.css'; -// import locale from 'element-ui/lib/locale/lang/en' // lang i18n - import '@/styles/index.scss'; // global css import LangStorage from '@/utils/lang'; import App from './App'; import VueI18n from 'vue-i18n'; + import store from './store'; import router from './router'; import '@/icons'; // icon import '@/permission'; // permission control import '@/scripts/GlobalPlugin'; -// import '@/directives'; import '@/directive/dialogDrag/index.js'; import '@/directive/dialogDragWidth/index.js'; import '@/directive/drag/index.js'; diff --git a/src/router/index.js b/src/router/index.js index d5e81c7cf..34aa055b8 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,7 +1,8 @@ -import Vue from 'vue'; +// import Vue from 'vue'; import Router from 'vue-router'; +// import VueRouter from 'vue-router'; -Vue.use(Router); +// Vue.use(Router); /* Layout */ const Layout = () => import('@/layout'); diff --git a/src/settings.js b/src/settings.js index a7ee1e069..8d143cfa9 100644 --- a/src/settings.js +++ b/src/settings.js @@ -1,16 +1,16 @@ module.exports = { - title: '', + title: '', - /** + /** * @type {boolean} true | false * @description Whether fix the header */ - fixedHeader: false, + fixedHeader: false, - /** + /** * @type {boolean} true | false * @description Whether show the logo in sidebar */ - sidebarLogo: false + sidebarLogo: false }; diff --git a/src/store/index.js b/src/store/index.js index 725ff1300..4dec2dc70 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,4 +1,4 @@ -import Vue from 'vue'; +// import Vue from 'vue'; import Vuex from 'vuex'; import app from './modules/app'; import settings from './modules/settings'; @@ -17,7 +17,7 @@ import ibp from './modules/ibp'; import getters from './getters'; -Vue.use(Vuex); +// Vue.use(Vuex); const store = new Vuex.Store({ modules: { diff --git a/vue.config.js b/vue.config.js index d99ea586f..41160b9e0 100644 --- a/vue.config.js +++ b/vue.config.js @@ -6,6 +6,10 @@ const defaultSettings = require('./src/settings.js'); const CopyWebpackPlugin = require('copy-webpack-plugin'); +// const CompressionWebpackPlugin = require('compression-webpack-plugin'); +// const productionGzipExtensions = ['js', 'css']; +// const isProduction = process.env.NODE_ENV === 'production'; + function resolve(dir) { return path.join(__dirname, dir); } @@ -47,30 +51,69 @@ module.exports = { // }, // after: require('./mock/mock-server.js') }, - configureWebpack: { - // provide the app's title in webpack's name field, so that - // it can be accessed in index.html to inject the correct title. - name: name, - resolve: { + configureWebpack: config => { + config.name = name; + config.resolve = { extensions: ['.js', '.vue', '.json'], alias: { '@': resolve('src') } - }, - plugins: [ - new CopyWebpackPlugin([ - { - from: path.resolve(__dirname, './static'), - to: 'static', - ignore: ['.*'] - } - ]) - ], - externals: { - 'echarts': 'echarts' // 配置使用CDN - // 'element-ui': 'ELEMENT' - } + }; + config.plugins.push(new CopyWebpackPlugin([ + { + from: path.resolve(__dirname, './static'), + to: 'static', + ignore: ['.*'] + } + ])); + + // if (isProduction) { + // config.plugins.push(new CompressionWebpackPlugin({ + // algorithm: 'gzip', + // test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'), + // threshold: 10240, + // minRatio: 0.8 + // })); + // } + + config.externals = { // 配置使用CDN + 'vue': 'Vue', + 'vuex': 'Vuex', + 'vue-router': 'VueRouter', + // 'nprogress': 'NProgress', + 'echarts': 'echarts' + }; + }, + // { + // // provide the app's title in webpack's name field, so that + // // it can be accessed in index.html to inject the correct title. + // name: name, + // resolve: { + // extensions: ['.js', '.vue', '.json'], + // alias: { + // '@': resolve('src') + // } + // }, + // plugins: [ + // new CopyWebpackPlugin([ + // { + // from: path.resolve(__dirname, './static'), + // to: 'static', + // ignore: ['.*'] + // } + // ]), + // new CompressionWebpackPlugin({ + // algorithm: 'gzip', + // test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'), + // threshold: 10240, + // minRatio: 0.8 + // }) + // ], + // externals: { + // 'echarts': 'echarts' // 配置使用CDN + // } + // }, chainWebpack(config) { config.plugins.delete('preload'); // TODO: need test config.plugins.delete('prefetch'); // TODO: need test