From 556c69213cdc107db68fa647d25a7a53a21c036e Mon Sep 17 00:00:00 2001 From: yma16 <17685043634@163.com> Date: Sun, 31 Jul 2022 23:10:53 +0800 Subject: [PATCH] =?UTF-8?q?perf:gzip=E6=89=93=E5=8C=85=E4=BC=98=E5=8C=96-b?= =?UTF-8?q?uild=E5=88=86=E6=94=AF=20dev=20=E9=85=8D=E7=BD=AE=E5=90=88?= =?UTF-8?q?=E5=85=A5master?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/webpack.dev.conf.js | 6 +++++- src/main.js | 26 +++++++++++--------------- src/router/index.js | 1 - src/store/index.js | 4 ++-- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/build/webpack.dev.conf.js b/build/webpack.dev.conf.js index 4dcd81e..34c7ece 100644 --- a/build/webpack.dev.conf.js +++ b/build/webpack.dev.conf.js @@ -13,6 +13,9 @@ const portfinder = require('portfinder') const HOST = process.env.HOST const PORT = process.env.PORT && Number(process.env.PORT) +//cdn 配置 +let externalConfig = [] + const devWebpackConfig = merge(baseWebpackConfig, { module: { rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }) @@ -55,7 +58,8 @@ const devWebpackConfig = merge(baseWebpackConfig, { new HtmlWebpackPlugin({ filename: 'index.html', template: 'index.html', - inject: true + inject: true, + cdnConfig: externalConfig, // cdn配置 }), // copy custom myblog_static assets new CopyWebpackPlugin([ diff --git a/src/main.js b/src/main.js index fe62c94..971194c 100644 --- a/src/main.js +++ b/src/main.js @@ -1,17 +1,19 @@ // The Vue build version to load with the `import` command // (runtime-only or standalone) has been set in webpack.base.conf with an alias. -// import Vue from 'vue' -// import VueRouter from 'vue-router' -// import axios from 'axios' -// import hljs from 'highlight.js' +//vue cdn +import Vue from 'vue' +import VueRouter from 'vue-router' +import axios from 'axios' +import hljs from 'highlight.js' +import importElementComponents from './importElement' +import importEchartsComponents from './importEchartsComponents' +// 样式cnd +import 'github-markdown-css/github-markdown.css' +import 'nprogress/nprogress.css' +// 无需cdn import useRouter from './router' import cookies from 'vue-cookies' import App from './App' -// import importElementComponents from './importElement' -// import importEchartsComponents from './importEchartsComponents' -// 样式 -// import 'github-markdown-css/github-markdown.css' -// import 'nprogress/nprogress.css' import 'highlight.js/styles/github.css' import * as echarts from 'echarts/core' @@ -23,12 +25,6 @@ if (env === 'production') { // 路由 const router = useRouter(Vue, VueRouter) - // // 按需引入elementui - // importElementComponents(Vue) - // - // // 按需引入echarts - // importEchartsComponents(Vue) - Vue.config.productionTip = false Vue.use(cookies) Vue.use(hljs) diff --git a/src/router/index.js b/src/router/index.js index dada4c1..db0edfe 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -9,7 +9,6 @@ const Bilicom = () => import('@/components/Bilicom') const Mavoneditor = () => import('@/components/Mavoneditor') const GrilShow = () => import('@/components/GrilShow') const Csslearn = () => import('@/components/Csslearn') - const defaultRoutes = [ { path: '/', diff --git a/src/store/index.js b/src/store/index.js index b1f7a9c..56a2d66 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,5 +1,5 @@ -// import Vue from 'vue' -// import Vuex from 'vuex' +import Vue from 'vue' +import Vuex from 'vuex' import persistedstate from 'vuex-persistedstate' -- GitLab