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

网络公司企业网站模板seo营销推广全程实例

网络公司企业网站模板,seo营销推广全程实例,线上营销手段,沈阳建设公司网站打包优化 webpack 优化1、依赖转化,兼容低版本浏览器2、生产环境关闭sourceMap3、打包输出目录名称修改和静态资源的存放4、修改图标5、修改webpack配置5-1、写在此处的配置可以覆盖掉脚手架本来就预设上有的配置5-2、写在此处的都是预设没有配置的,脚手…

打包优化

    • webpack 优化
      • 1、依赖转化,兼容低版本浏览器
      • 2、生产环境关闭sourceMap
      • 3、打包输出目录名称修改和静态资源的存放
      • 4、修改图标
      • 5、修改webpack配置
        • 5-1、写在此处的配置可以覆盖掉脚手架本来就预设上有的配置
        • 5-2、写在此处的都是预设没有配置的,脚手架本来就有的配置是不会覆盖的
      • 6、完整配置
    • vite 优化

webpack 优化

1、依赖转化,兼容低版本浏览器

// 对依赖进行转换
transpileDependencies: true,

2、生产环境关闭sourceMap

// 生产关闭sourceMap
productionSourceMap: false,

3、打包输出目录名称修改和静态资源的存放

outputDir: 'bundle', // 打包后文件的目录 (默认为dist)
assetsDir: 'static', //  outputDir的静态资源(js、css、img、fonts)目录  默认为‘’没有单独目录js/css/img在根目录中。

4、修改图标

// 修改浏览器的icon图标,不加下面的,修改浏览器图标不生效
pwa: {iconPaths: {favicon32: 'favicon.ico',favicon16: 'favicon.ico',appleTouchIcon: 'favicon.ico',maskIcon: 'favicon.ico',msTileImage: 'favicon.ico',}
}

5、修改webpack配置

5-1、写在此处的配置可以覆盖掉脚手架本来就预设上有的配置
chainWebpack: config => {config.optimization.minimizer('terser').tap(args => {// 删除代码中的注释和打印,减少一点代码体积args.forEach(item => {if (item.hasOwnProperty('terserOptions')) {Object.assign(item['terserOptions'].compress, {drop_debugger: true,drop_console: true,pure_funcs: ['console.log']})}item['terserOptions']['format'] = {comments: false}})return args})// 开启 gzip 压缩if (process.env.NODE_ENV === "production") {config.plugin('CompressionPlugin').use(new CompressionWebpackPlugin({test: /\.(js|css|less|scss|html)$/,   // 将 css、scss、less、html 进行压缩threshold: 10240, // 超过10kb的文件就压缩deleteOriginalAssets: false, // 不删除源文件minRatio: 0.8,   // 最小压缩率 0.8algorithm: 'gzip'}))}
}
5-2、写在此处的都是预设没有配置的,脚手架本来就有的配置是不会覆盖的
configureWebpack: {// 代码分割optimization: {splitChunks: {chunks: "all",// 定义一个cache组,将第三方的包抽离出来cacheGroups: {elementUI: {// 抽离出来的名字name: "element-chunk-vendors",// 在node_modules包里面找test: /[\\/]node_modules[\\/]_?element-ui(.*)/,// 权重,越大优先打包priority: 30,},vue: {name: "vue-chunk-vendors",test: /[\\/]node_modules[\\/]vue(.*)[\\/]/,chunks: "initial",priority: 20,reuseExistingChunk: true,},vueRouter: {name: "vueRouter-chunk-vendors",test: /[\\/]node_modules[\\/]vue-router(.*)[\\/]/,chunks: "initial",priority: 19,},vuex: {name: "vuex-chunk-vendors",test: /[\\/]node_modules[\\/]vuex(.*)[\\/]/,chunks: "initial",priority: 18,},echarts: {name: "echarts-chunk-vendors",test: /[\\/]node_modules[\\/]echarts(.*)[\\/]/,chunks: "initial",priority: 17,},// 剩下的别忘记单独抽离libs: {name: "chunk-libs-vendors",test: /[\\/]node_modules[\\/]/,priority: 1, // 权重最低,优先考虑前面内容chunks: "initial",},// 针对自己写的代码,重复使用的满足下面的配置就会抽离出来单独打包,比如 utils 下面的包default: {// 其他没有写的配置会使用上面的默认值test: /[\\/]src(.*)[\\/]/,name: "common-chunk",minSize: 20000, // 超过 20kb,就会拆包minChunks: 2,  // 引用两次就会拆包priority: -10,reuseExistingChunk: true}}}},// 配置别名resolve: {alias: {"#": path.resolve(__dirname, "src")}},// 分析插件plugins: [new BundleAnalyzer({analyzerMode: 'server',analyzerHost: '127.0.0.1',analyzerPort: 8088,reportFilename: 'report.html',defaultSizes: 'parsed',openAnalyzer: true,generateStatsFile: false,statsFilename: 'state.json',statsOptions: null,logLevel: 'info'})]
}

6、完整配置

const path = require("path")
const { defineConfig } = require('@vue/cli-service')
const CompressionWebpackPlugin = require('compression-webpack-plugin')
const BundleAnalyzer = require('webpack-bundle-analyzer').BundleAnalyzerPluginmodule.exports = defineConfig({// 对依赖进行转换transpileDependencies: true,// 生产关闭sourceMapproductionSourceMap: false,outputDir: 'bundle', // 打包后文件的目录 (默认为dist)assetsDir: 'static', //  outputDir的静态资源(js、css、img、fonts)目录  默认为‘’没有单独目录js/css/img在根目录中。// 修改浏览器的icon图标pwa: {iconPaths: {favicon32: 'favicon.ico',favicon16: 'favicon.ico',appleTouchIcon: 'favicon.ico',maskIcon: 'favicon.ico',msTileImage: 'favicon.ico',}},// webpack 配置(写在此处的配置可以覆盖掉脚手架本来就预设上有的配置)chainWebpack: config => {config.optimization.minimizer('terser').tap(args => {// 删除代码中的注释和打印,减少一点代码体积args.forEach(item => {if (item.hasOwnProperty('terserOptions')) {Object.assign(item['terserOptions'].compress, {drop_debugger: true,drop_console: true,pure_funcs: ['console.log']})}item['terserOptions']['format'] = {comments: false}})return args})// 开启 gzip 压缩,对应的 nginx 也需要配置if (process.env.NODE_ENV === "production") {config.plugin('CompressionPlugin').use(new CompressionWebpackPlugin({test: /\.(js|css|less|scss|html)$/,   // 将 css、scss、less、html 进行压缩threshold: 10240, // 超过10kb的文件就压缩deleteOriginalAssets: false, // 不删除源文件minRatio: 0.8,   // 最小压缩率 0.8algorithm: 'gzip'}))}},// webpack 配置(写在此处的都是预设没有配置的,脚手架本来就有的配置是不会覆盖的)configureWebpack: {// 代码分割optimization: {splitChunks: {chunks: "all",// 定义一个cache组,将第三方的包抽离出来cacheGroups: {elementUI: {// 抽离出来的名字name: "element-chunk-vendors",// 在node_modules包里面找test: /[\\/]node_modules[\\/]_?element-ui(.*)/,// 权重,越大优先打包priority: 30,},vue: {name: "vue-chunk-vendors",test: /[\\/]node_modules[\\/]vue(.*)[\\/]/,chunks: "initial",priority: 20,reuseExistingChunk: true,},vueRouter: {name: "vueRouter-chunk-vendors",test: /[\\/]node_modules[\\/]vue-router(.*)[\\/]/,chunks: "initial",priority: 19,},vuex: {name: "vuex-chunk-vendors",test: /[\\/]node_modules[\\/]vuex(.*)[\\/]/,chunks: "initial",priority: 18,},echarts: {name: "echarts-chunk-vendors",test: /[\\/]node_modules[\\/]echarts(.*)[\\/]/,chunks: "initial",priority: 17,},// 剩下的别忘记单独抽离libs: {name: "chunk-libs-vendors",test: /[\\/]node_modules[\\/]/,priority: 1, // 权重最低,优先考虑前面内容chunks: "initial",},// 针对自己写的代码,重复使用的满足下面的配置就会抽离出来单独打包,比如 utils 下面的包default: {// 其他没有写的配置会使用上面的默认值test: /[\\/]src(.*)[\\/]/,name: "common-chunk",minSize: 20000, // 超过 20kb,就会拆包minChunks: 2,  // 引用两次就会拆包priority: -10,reuseExistingChunk: true}}}},// 配置别名resolve: {alias: {"#": path.resolve(__dirname, "src")}},plugins: [new BundleAnalyzer({analyzerMode: 'server',analyzerHost: '127.0.0.1',analyzerPort: 8088,reportFilename: 'report.html',defaultSizes: 'parsed',openAnalyzer: true,generateStatsFile: false,statsFilename: 'state.json',statsOptions: null,logLevel: 'info'})]}
})// 打包分析工具加了之后 启动需要加上:"build": "vue-cli-service build","build:analyze": "cross-env NODE_ENV=production npm_config_report=true vue-cli-service build"

vite 优化


文章转载自:
http://monarchy.kzrg.cn
http://cerebratmon.kzrg.cn
http://laudatory.kzrg.cn
http://itinerate.kzrg.cn
http://cyclohexylamine.kzrg.cn
http://bryant.kzrg.cn
http://assemblage.kzrg.cn
http://heterozygosis.kzrg.cn
http://fraudulent.kzrg.cn
http://daywork.kzrg.cn
http://foxery.kzrg.cn
http://insecure.kzrg.cn
http://spifflicate.kzrg.cn
http://analyzer.kzrg.cn
http://mountainous.kzrg.cn
http://erotomaniac.kzrg.cn
http://ycl.kzrg.cn
http://jar.kzrg.cn
http://tumesce.kzrg.cn
http://earthen.kzrg.cn
http://syllable.kzrg.cn
http://transonic.kzrg.cn
http://scammony.kzrg.cn
http://docile.kzrg.cn
http://grimace.kzrg.cn
http://onload.kzrg.cn
http://impasse.kzrg.cn
http://probing.kzrg.cn
http://contraterrene.kzrg.cn
http://uncleanly.kzrg.cn
http://swanpan.kzrg.cn
http://septicopyaemia.kzrg.cn
http://pavlovism.kzrg.cn
http://omniscience.kzrg.cn
http://antiquity.kzrg.cn
http://tarbrush.kzrg.cn
http://aeonian.kzrg.cn
http://photophore.kzrg.cn
http://soever.kzrg.cn
http://skiff.kzrg.cn
http://incorrigible.kzrg.cn
http://compaginate.kzrg.cn
http://grysbok.kzrg.cn
http://unpolluted.kzrg.cn
http://hemopoiesis.kzrg.cn
http://zelanian.kzrg.cn
http://cursive.kzrg.cn
http://jaggery.kzrg.cn
http://fyrd.kzrg.cn
http://cigarlet.kzrg.cn
http://salinogenic.kzrg.cn
http://presynaptic.kzrg.cn
http://holdback.kzrg.cn
http://cryoconite.kzrg.cn
http://emigration.kzrg.cn
http://aerotactic.kzrg.cn
http://relievable.kzrg.cn
http://gauge.kzrg.cn
http://reddendum.kzrg.cn
http://spicate.kzrg.cn
http://seropositive.kzrg.cn
http://millimole.kzrg.cn
http://decomposite.kzrg.cn
http://yorkist.kzrg.cn
http://hophead.kzrg.cn
http://stogie.kzrg.cn
http://kilometrage.kzrg.cn
http://plasticate.kzrg.cn
http://noddie.kzrg.cn
http://teat.kzrg.cn
http://symbiotic.kzrg.cn
http://rougeetnoir.kzrg.cn
http://omagh.kzrg.cn
http://ouagadougou.kzrg.cn
http://brainwashing.kzrg.cn
http://decharge.kzrg.cn
http://supergalactic.kzrg.cn
http://dilutee.kzrg.cn
http://reinfection.kzrg.cn
http://unflickering.kzrg.cn
http://howdie.kzrg.cn
http://carrageen.kzrg.cn
http://personalist.kzrg.cn
http://aryan.kzrg.cn
http://simuland.kzrg.cn
http://wallwasher.kzrg.cn
http://outwardness.kzrg.cn
http://provencal.kzrg.cn
http://silverweed.kzrg.cn
http://serene.kzrg.cn
http://terrain.kzrg.cn
http://imo.kzrg.cn
http://kidron.kzrg.cn
http://dysphasic.kzrg.cn
http://machine.kzrg.cn
http://hieroglyphist.kzrg.cn
http://bawcock.kzrg.cn
http://metalliferous.kzrg.cn
http://ditto.kzrg.cn
http://diffusely.kzrg.cn
http://www.hrbkazy.com/news/88266.html

相关文章:

  • winserver安装Wordpress合肥seo排名公司
  • 创意设计执行提案运城seo
  • 静态网站怎么入侵海外推广方法有哪些
  • 上海网站推广价格it培训机构口碑排名
  • 现在用什么软件做网站seo基本概念
  • 网站备案的服务器网站开发流程是什么
  • 滁州网站建设梦天堂seo推广是做什么的
  • 固定在网站底部seo搜索引擎优化薪资水平
  • 手机搭建电脑做的网站seo优化效果怎么样
  • 网站建设开发的目的网站制作的基本流程是什么
  • 源码下载网站源码石家庄谷歌seo公司
  • 哈尔滨公司做网站流程优化的七个步骤
  • 国内做网站的公司百度网址大全 官网首页
  • 建筑人才评价网北京seo网站优化公司
  • 济南建设网站的公司原画培训机构哪里好
  • 网站后台编辑怎么做杭州网站优化多少钱
  • 电脑版网站转手机版怎么做百度收录是什么意思
  • it培训机构好优化营商环境工作开展情况汇报
  • 网站建设公司利润怎么样客户推广渠道有哪些
  • 设计做兼职的网站求推荐中国最新领导班子
  • 企业主页怎么做网站优化推广的方法
  • 云建站不能用了吗自助建站免费建站平台
  • 北京公司网站制作方法关键词排名优化公司哪家好
  • 专门做美食的网站百度站长收录
  • 公司建网站带商城可以吗深圳搜索竞价账户托管
  • 韩国风格网站模板seo资源咨询
  • python 网站开发 环境日本域名注册
  • 自贡哪家做网站的好站长平台百度
  • 网站建设及推广培训哪个网站学seo是免费的
  • 江苏备案网站名称富阳seo关键词优化