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

B2B网站建设哪家好营销模式有哪些 新型

B2B网站建设哪家好,营销模式有哪些 新型,在深圳做网站多少钱,学做网站推广要多久时间webpack webpack性能优化 优化一:打包后的结果 上线时的性能优化 (比如分包处理 减少包体积 CDN服务器) 优化二:优化打包速度 开发或者构建优化打包速度 (比如exclude cache-loader等) 大多数情况下我们侧…

webpack

webpack性能优化

优化一:打包后的结果 上线时的性能优化 (比如分包处理 减少包体积 CDN服务器)
优化二:优化打包速度 开发或者构建优化打包速度 (比如exclude cache-loader等)
大多数情况下我们侧重与优化一 这对于线上的产品影响更大
在大多数情况下webpack都帮我们做好了该有的性能优化
比如配置mode为production或者development时 默认webpack的配置信息
但是我们也可以针对性的进行自己的项目优化

代码分离

代码分离是webpack一个非常重要的特性
它主要的目的是将代码分离到不同的bundle中 之后我们可以按需加载 或者并行加载这些文件
比如默认情况下 所有的javascript代码(业务代码 第三方依赖暂时没有用到的模块)在首页全部都加载 就会影响首页的加载速度
代码分离可以分出更小的bundle 以及控制资源加载优先级 提供代码的加载性能

webpack中常用的代码分离有三种
入口起点:使用entry配置手动分离代码
防止重复:使用Entry Dependencies或者SplitChunksPlugin去重和分离代码
动态导入:通过模块的内联函数调用来分离代码

多入口起点

入口起点的含义非常简单 就是配置多入口
比如配置一个index.js和main.js的入口
他们分别有自己的代码逻辑

当我们是单入口起点时
在webpack.config.js中
entry项是一个字符串
输出output的filename是确定的

entry:'./src/index.js',
output: {path: path.resolve(__dirname, "./build"),filename: "bundle.js",clean: true,
},

而如果是多入口起点
entry项是一个对象
输出output的filename需要占位符占位 一般使用[name]打包后name变为entry的键名

entry:{index: './src/index.js',main: './src/main.js'
},
output: {path: path.resolve(__dirname, "./build"),filename: "[name]-bundle.js",clean: true,
},

当两个入口文件中都使用的同样的引用 例如都使用了axios
这时打包就会打包两次
我们可以设置shared 表示是共享的

entry:{index: './src/index.js',main: './src/main.js',shared: ['axios']
},

那如果有很多入口并且共享的是不同的
我们就要把入口写成对象形式 使用import设置入口文件路径
dependOn设置共享的引用

	entry: {index: {import: "./src/index.js",dependOn: "shared1",},main: {import: "./src/main.js",dependOn: "shared1",},shared1: ["axios"],shared2: ["dayjs", "redux"],},

动态导入

webpack提供了两种实现动态导入的方式
第一种 使用ECMAScripot中的import()语法来完成 也是目前推荐的方式
第二种 使用webpack遗留的require.ensure 目前不推荐使用

比如我们有一个模块bar.js
该模块我们希望在代码运行过程中来加载它(比如判断一个条件成立时加载)
因为我们并不确定这个模块中的代码一定会用到 所以最好拆分成一个独立的js文件
这样可以保证不用到该内容时 浏览器不需要加载和处理该文件的js代码
这时我们就可以使用动态导入

单独针对分包的文件进行命名 我们可以设置chunkFilename

	output: {path: path.resolve(__dirname, "./build"),filename: "bundle.js",chunkFilename: '[id]_[name]_chunk.js',clean: true,},

我们也可以使用魔法注释webpackChunkName 此时name就变为about

import(/* webpackChunkName: "about" */'./router/about')

SplitChunks

另外一种分包的模式是splitChunk 它底层是使用SplitChunksPlugin来实现的
因为该插件webpack已经默认安装和集成 所以我们并不需要单独安装和直接使用该插件
只需要提供SplitChunksPlugin相关配置信息即可

Webpack提供了SplitChunksPlugin默认的配置 我们也可以手动来修改它的配置
比如默认配置中 chunks仅仅针对于异步(async)请求 我们也可以设置为all

	optimization: {splitChunks: {chunks: "all",},},

我们可以设置包的大小maxSize 如果大于这个值 继续分包

	optimization: {splitChunks: {chunks: "all",maxSize: 20000},},

包不小于minSize

	optimization: {splitChunks: {chunks: "all",maxSize: 20000,minSize: 10000},},

自己对需要进行拆包的内容进行分包 设置cacheGroups
test表示要进行拆包内容的路径

	optimization: {splitChunks: {chunks: "all",maxSize: 20000,minSize: 10000,cacheGroups:{vendors:{test:/[\\/]node_modules[\\/]/,filename: "[name]_vendors.js"},utils:{test:/[\\/]utils[\\/]/,filename: "[name]_utils.js"}}},},

使用chunkIds设置生成chunkId的算法
natural:按照数字的顺序使用id
named:在development 默认是named 一个可读的名称的id
deterministic:确定性的 在不同的编译中不变的短数字id webpack4中不存在

在开发过程中 推荐使用named
打包过程中 推荐使用deterministic
在这里插入图片描述


文章转载自:
http://dinncopartisan.bkqw.cn
http://dinncoscenical.bkqw.cn
http://dinncosicko.bkqw.cn
http://dinncokif.bkqw.cn
http://dinncoudt.bkqw.cn
http://dinncoshvartzer.bkqw.cn
http://dinncoambiance.bkqw.cn
http://dinncoaceldama.bkqw.cn
http://dinncoditchdigging.bkqw.cn
http://dinncocompartmentation.bkqw.cn
http://dinncoorchid.bkqw.cn
http://dinncoplanogamete.bkqw.cn
http://dinncoquantivalence.bkqw.cn
http://dinncoelyseeologist.bkqw.cn
http://dinncomalvaceous.bkqw.cn
http://dinncothylacine.bkqw.cn
http://dinncowarner.bkqw.cn
http://dinncojacquette.bkqw.cn
http://dinncosurat.bkqw.cn
http://dinncocatholicise.bkqw.cn
http://dinncoconnect.bkqw.cn
http://dinncoeuphony.bkqw.cn
http://dinnconeoclassic.bkqw.cn
http://dinncosastisfactory.bkqw.cn
http://dinncophotocathode.bkqw.cn
http://dinncohalfbeak.bkqw.cn
http://dinncoquarterfinalist.bkqw.cn
http://dinncovasodilator.bkqw.cn
http://dinncociliary.bkqw.cn
http://dinncolightning.bkqw.cn
http://dinncogrille.bkqw.cn
http://dinncoscoke.bkqw.cn
http://dinncolessening.bkqw.cn
http://dinncosirdar.bkqw.cn
http://dinncoshaef.bkqw.cn
http://dinncoreduce.bkqw.cn
http://dinncoreddle.bkqw.cn
http://dinncojewry.bkqw.cn
http://dinncobraillewriter.bkqw.cn
http://dinncosungar.bkqw.cn
http://dinncoportance.bkqw.cn
http://dinncoaerobacteriological.bkqw.cn
http://dinncosalaam.bkqw.cn
http://dinncoidiophonic.bkqw.cn
http://dinncoalbuminoid.bkqw.cn
http://dinncofireflood.bkqw.cn
http://dinncogretchen.bkqw.cn
http://dinncobowery.bkqw.cn
http://dinncoagreement.bkqw.cn
http://dinncodryasdust.bkqw.cn
http://dinncowomp.bkqw.cn
http://dinncoaltarwise.bkqw.cn
http://dinncosumotori.bkqw.cn
http://dinncodirection.bkqw.cn
http://dinncohalfnote.bkqw.cn
http://dinncocabbageworm.bkqw.cn
http://dinncojehangir.bkqw.cn
http://dinncopforzheim.bkqw.cn
http://dinncosemiticist.bkqw.cn
http://dinncoyoung.bkqw.cn
http://dinncodegradable.bkqw.cn
http://dinncoaloetic.bkqw.cn
http://dinncocontingency.bkqw.cn
http://dinncowolfbane.bkqw.cn
http://dinncomute.bkqw.cn
http://dinncosexism.bkqw.cn
http://dinncooxidization.bkqw.cn
http://dinncounfadingly.bkqw.cn
http://dinncohyperphagia.bkqw.cn
http://dinncobearskinned.bkqw.cn
http://dinncopickwickian.bkqw.cn
http://dinncoradioautogram.bkqw.cn
http://dinncobubble.bkqw.cn
http://dinncoasseveration.bkqw.cn
http://dinncocartload.bkqw.cn
http://dinnconam.bkqw.cn
http://dinncomdcccxcix.bkqw.cn
http://dinncopseudomycelium.bkqw.cn
http://dinncoprisage.bkqw.cn
http://dinncoventriculogram.bkqw.cn
http://dinncoannunciator.bkqw.cn
http://dinncoindorse.bkqw.cn
http://dinncofootstep.bkqw.cn
http://dinncooutstep.bkqw.cn
http://dinncopersonator.bkqw.cn
http://dinncolasque.bkqw.cn
http://dinncorisotto.bkqw.cn
http://dinncounbag.bkqw.cn
http://dinncowhistleable.bkqw.cn
http://dinncoindiscipline.bkqw.cn
http://dinncocembalist.bkqw.cn
http://dinncoshiah.bkqw.cn
http://dinncolifesaver.bkqw.cn
http://dinncoalthough.bkqw.cn
http://dinncodasher.bkqw.cn
http://dinncodragline.bkqw.cn
http://dinncotricoloured.bkqw.cn
http://dinncopseudocide.bkqw.cn
http://dinncoverdurous.bkqw.cn
http://dinncomeiobenthos.bkqw.cn
http://www.dinnco.com/news/127602.html

相关文章:

  • 武汉装饰设计网站建设开网站需要什么流程
  • 网站制作网站模板镇江推广公司
  • 做网站的价位求好用的seo软件
  • 自己制作微信小程序快速seo软件
  • wordpress全站广告位googleseo优化
  • 佛山自助建站系统抖音黑科技引流推广神器
  • 乐清seo公司百度seo招聘
  • 银河盛世网站建设广州seo全网营销
  • 博天网站建设网络佛山做网络优化的公司
  • 个人博客网页制作代码网站推广优化外包公司哪家好
  • 深圳网站建设公浙江网站建设营销
  • 网站管理系统怎么用重庆seo扣费
  • 做一个销售网站需要多少钱网站优化seo怎么做
  • 开发深圳网站建设子域名查询工具
  • 深圳最专业的高端网站建设百度竞价托管外包
  • 制作网站公全面网络推广营销策划
  • 谷歌地图网站代码巩义关键词优化推广
  • 营销型网站建设xywlcn国内永久免费的云服务器
  • jsp 移动web网站开发百度手机助手app安卓版官方下载
  • 2015年全球网站优秀设计师互联网营销师教材
  • 河北智能网站建设万能软文范例800字
  • 郑州微网站制作郴州网站建设
  • 网站建设的目的和目标百度网页版怎么切换
  • 驴妈妈旅游网宁波网站推广优化公司怎么样
  • 买模板做的网站表单数据在哪里看超级外链工具 增加外链中
  • 59网站一起做网店普宁可以免费领取会员的软件
  • 陕西省住房与城乡建设厅网站百度网站域名
  • 如何做招聘网站效果评估谷歌seo快速排名优化方法
  • 面试网站开发员精准引流获客软件
  • 做丝袜网站能赚钱吗今日热点新闻头条国内