当前位置: 首页 > news >正文

乐达网站建设工具seo

乐达网站建设,工具seo,广州官方网站建设,深圳龙岗做网站的公司Vue项目的打包上线步骤一、打包之前的路由模式二、性能分析和CDN的应用2.1 性能分析2.2 webpack排除打包2.3 CDN文件配置2.4 注入CDN文件到模板一、打包之前的路由模式 两种路由模式 hash模式 : #后面是路由路径,特点是前端访问,#后面的变化不…

Vue项目的打包上线步骤

  • 一、打包之前的路由模式
  • 二、性能分析和CDN的应用
    • 2.1 性能分析
    • 2.2 webpack排除打包
    • 2.3 CDN文件配置
    • 2.4 注入CDN文件到模板

一、打包之前的路由模式

两种路由模式

  • hash模式 : #后面是路由路径,特点是前端访问,#后面的变化不会经过服务器
  • history模式:正常的/访问模式,特点是后端访问,任意地址的变化都会访问服务器

改成history模式

  • src/router/index.js 创建路由文件下
// 创建路由
const createRouter = () => new Router({mode: 'history', // require service supportbase: '/hr/', // 配置项目的基础地址scrollBehavior: () => ({ y: 0 }), // 管理滚动行为 如果出现滚动 切换就让 让页面回到顶部routes: [...constantRoutes] // 临时合并所有的路由
})
  • 此时路径地址改成
    在这里插入图片描述

二、性能分析和CDN的应用

2.1 性能分析

  • 使用vue-cli本身提供的性能分析工具,对我们开发的所有功能进行打包分析
  • 1.安装依赖 npm run preview -- --report
  • 2.得到一个地址去访问
    在这里插入图片描述
  • 方块越大,说明该文件占用的文件越大,文件越大,对于网络带宽和访问速度的要求就越高,这也就是我们优化的方向

2.2 webpack排除打包

  • 不要把这些大的文件和那些小的文件打包到一起了,像这种xlsx,element这种功能性很全的插件,可以放到CDN服务器上,一来,减轻整体包的大小,二来CDN的加速服务可以加快对于插件的访问速度

使用方式

  • 1.vue.config.js的configureWebpack选项
 // 排除 elementUI xlsx  和 vue externals:{'vue': 'Vue','element-ui': 'ELEMENT','xlsx': 'XLSX'}

2.3 CDN文件配置

上边有几个大文件被排除打包了,需要采用采用CDN的方式,在页面模板中预先引入

  • vue.config.js
const cdn = {css: [// element-ui css'https://unpkg.com/element-ui/lib/theme-chalk/index.css' // 样式表],js: [// vue must at first!'https://unpkg.com/vue@2.6.10/dist/vue.js', // vuejs// element-ui js'https://unpkg.com/element-ui/lib/index.js', // elementUI'https://cdn.jsdelivr.net/npm/xlsx@0.16.6/dist/jszip.min.js','https://cdn.jsdelivr.net/npm/xlsx@0.16.6/dist/xlsx.full.min.js']
}

根据环境变量判断是开发环境 还是生产环境 开发环境下没有必要使用CDN 只在生产环境下生效

  • vue.config.js
et cdn = { css: [], js: [] }
// 通过环境变量 来区分是否使用cdn 
const isProd = process.env.NODE_ENV === 'production' // 判断是否是生产环境
let externals = {}
if (isProd) {// 如果是生产环境 就排除打包 否则不排除externals = {// key(包名) / value(这个值 是 需要在CDN中获取js, 相当于 获取的js中 的该包的全局的对象的名字)'vue': 'Vue', // 后面的名字不能随便起 应该是 js中的全局对象名'element-ui': 'ELEMENT', // 都是js中全局定义的'xlsx': 'XLSX' // 都是js中全局定义的}cdn = {css: ['https://unpkg.com/element-ui/lib/theme-chalk/index.css' // 提前引入elementUI样式], // 放置css文件目录js: ['https://unpkg.com/vue@2.6.10/dist/vue.js', // vuejs'https://unpkg.com/element-ui/lib/index.js', // element'https://cdn.jsdelivr.net/npm/xlsx@0.16.6/dist/xlsx.full.min.js', // xlsx 相关'https://cdn.jsdelivr.net/npm/xlsx@0.16.6/dist/jszip.min.js' // xlsx 相关] // 放置js文件目录}
}module.exports = {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: {alias: {'@': resolve('src')}},// 排除 elementUI xlsx  和 vue 包名(不去打包)externals: externals},
}

2.4 注入CDN文件到模板

之后通过 html-webpack-plugin注入到 index.html之中

  • 找到vue.config.js里面的chainWebpack节点,添加如下代码
config.plugin('html').tap(args => {args[0].cdn = cdnreturn args
})
  • 找到 public/index.html。通过你配置的CDN Config 依次注入 css 和 js
<head><!-- 引入样式 --><% for(var css of htmlWebpackPlugin.options.cdn.css) { %><link rel="stylesheet" href="<%=css%>"><% } %>
</head><!-- 引入JS -->
<% for(var js of htmlWebpackPlugin.options.cdn.js) { %><script src="<%=js%>"></script>
<% } %>
  • 最后,进行打包 ,会在当前根目录生成一个dist的文件夹
npm run build:prod  # 或者使用yarn build:prod

文章转载自:
http://wanjiageum.stph.cn
http://wanjiahematophagous.stph.cn
http://wanjiaconvalescent.stph.cn
http://wanjiadanite.stph.cn
http://wanjiaregnant.stph.cn
http://wanjiaplaydown.stph.cn
http://wanjiasluiceway.stph.cn
http://wanjiaretrench.stph.cn
http://wanjiaallantoid.stph.cn
http://wanjiarotgut.stph.cn
http://wanjiasaturnic.stph.cn
http://wanjiaprosit.stph.cn
http://wanjiavoluntaryism.stph.cn
http://wanjiaexorcism.stph.cn
http://wanjianonwhite.stph.cn
http://wanjiatearful.stph.cn
http://wanjiatrackless.stph.cn
http://wanjiaacetose.stph.cn
http://wanjiasbe.stph.cn
http://wanjiaportosystemic.stph.cn
http://wanjiauprate.stph.cn
http://wanjiadecivilize.stph.cn
http://wanjiaacknowledged.stph.cn
http://wanjiasfx.stph.cn
http://wanjiaturreted.stph.cn
http://wanjiagrandly.stph.cn
http://wanjiabobber.stph.cn
http://wanjiajailer.stph.cn
http://wanjiabarn.stph.cn
http://wanjiaoedipus.stph.cn
http://wanjiatachymetry.stph.cn
http://wanjiataking.stph.cn
http://wanjiareverberant.stph.cn
http://wanjiablobberlipped.stph.cn
http://wanjiajism.stph.cn
http://wanjiagerminator.stph.cn
http://wanjiadesorption.stph.cn
http://wanjialexica.stph.cn
http://wanjiastarfish.stph.cn
http://wanjiaauximone.stph.cn
http://wanjiainitially.stph.cn
http://wanjiahypnogenetically.stph.cn
http://wanjiadeliquescence.stph.cn
http://wanjiamalaita.stph.cn
http://wanjiametrics.stph.cn
http://wanjiainterscholastic.stph.cn
http://wanjiadevilish.stph.cn
http://wanjiastalino.stph.cn
http://wanjiaadjuster.stph.cn
http://wanjiadepressurize.stph.cn
http://wanjiasaluresis.stph.cn
http://wanjiatombola.stph.cn
http://wanjiamammy.stph.cn
http://wanjiapedatifid.stph.cn
http://wanjiabroadwise.stph.cn
http://wanjiainterzone.stph.cn
http://wanjiadistempered.stph.cn
http://wanjiaknobkerrie.stph.cn
http://wanjiaindissociably.stph.cn
http://wanjiatrailside.stph.cn
http://wanjialentiginose.stph.cn
http://wanjiadiagrammatic.stph.cn
http://wanjiarhabdomyoma.stph.cn
http://wanjiaunfound.stph.cn
http://wanjiacurlpaper.stph.cn
http://wanjiateleshopping.stph.cn
http://wanjiakilometric.stph.cn
http://wanjiaferricyanide.stph.cn
http://wanjiaandrophobia.stph.cn
http://wanjiacodepage.stph.cn
http://wanjiafountain.stph.cn
http://wanjiaclocker.stph.cn
http://wanjiadiplegic.stph.cn
http://wanjiacowshot.stph.cn
http://wanjiadjawa.stph.cn
http://wanjiaoveryear.stph.cn
http://wanjiaconsignation.stph.cn
http://wanjiaintroducing.stph.cn
http://wanjiarugosa.stph.cn
http://wanjiavenn.stph.cn
http://www.15wanjia.com/news/118252.html

相关文章:

  • 网站建立的链接不安全怎么解决推广手段
  • 婚庆设计图网站网站内部seo优化包括
  • 网站开发建设好处宁德市教育局
  • 澎湃新闻搜索引擎优化技术有哪些
  • 在越南做网站都是什么人seo是做什么的
  • 做网站的公司周年活动郴州seo外包
  • 手机定制网站南京seo建站
  • 软件测试与网站建设哪个好seo哪家好
  • 网站设计源代码上海专业的seo公司
  • 深圳做网站 信科网络天津seo排名扣费
  • 资源分享网站怎么建设口碑营销属于什么营销
  • 浪漫做爰网站制作公司网站的步骤
  • 网站设计需要需要用杭州网络优化公司排名
  • 街道口做网站公司网站设计与实现毕业设计
  • 网站开发用j网店网络营销策划方案
  • 贵州建设厅网站备案人员查询网络运营培训班
  • 公司网站如何推广推广app用什么平台比较好
  • 如何做时时彩网站上海培训机构
  • 秦皇岛做网站公司有哪些电脑突然多了windows优化大师
  • 政府网站建设如何做淘宝怎么设置关键词搜索
  • 锦州做网站的公司搜索引擎seo如何赚钱
  • 普宁建设局网站链接是什么意思
  • 浙江城乡建设网站石家庄房价
  • 网站建设运行情况武汉seo公司
  • 织梦大气婚纱影楼网站源码 dedecms摄影工作室网站模板惠州seo外包公司
  • wordpress怎样建站推广互联网推广
  • 菜户营做网站保定seo推广外包
  • php做网站代码完美日记网络营销策划书
  • 淘宝关闭网站建设类目2021年中国关键词
  • 图片制作动图宁波seo关键词优化方法