JavaScript系列(87)--Webpack 高级配置详解

Webpack 高级配置详解 🛠️

Webpack 是前端工程化中最流行的构建工具之一,掌握其高级配置可以帮助我们构建更高效、更优化的应用。本文将深入探讨Webpack的高级配置技巧和最佳实践。

Webpack 核心概念回顾 🌟

💡 小知识:Webpack 本质上是一个现代 JavaScript 应用程序的静态模块打包器。当 Webpack 处理应用程序时,它会递归地构建一个依赖关系图,其中包含应用程序需要的每个模块,然后将所有这些模块打包成一个或多个 bundle。

代码分割策略 📦

// 1. 基于入口的代码分割
class EntryPointSplitting {static createConfig() {return {entry: {main: './src/index.js',vendor: './src/vendor.js',admin: './src/admin.js'},output: {filename: '[name].[contenthash].js',path: path.resolve(__dirname, 'dist')},optimization: {runtimeChunk: 'single'}};}
}// 2. 动态导入
class DynamicImports {static asyncComponent() {return `// 路由级别的代码分割const UserProfile = () => import(/* webpackChunkName: "profile" */'./components/UserProfile');// 条件加载const loadAnalytics = () => {if (process.env.NODE_ENV === 'production') {import(/* webpackChunkName: "analytics" */ './analytics').then(module => module.default()).catch(err => console.error('Failed to load analytics:', err));}};`;}static preloadComponent() {return `// 预加载重要资源import(/* webpackChunkName: "important" *//* webpackPreload: true */'./important-module');// 预获取未来可能需要的资源import(/* webpackChunkName: "future" *//* webpackPrefetch: true */'./future-module');`;}
}// 3. SplitChunksPlugin 配置
class SplitChunksConfig {static getAdvancedConfig() {return {optimization: {splitChunks: {chunks: 'all',maxInitialRequests: Infinity,minSize: 20000,cacheGroups: {vendor: {test: /[\\/]node_modules[\\/]/,name(module) {// 获取npm包名 (例如:node_modules/packageName/...)const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];// npm包名转换为有效的文件名return `npm.${packageName.replace('@', '')}`;}},common: {name: 'common',minChunks: 2,priority: 10,reuseExistingChunk: true}}}}};}
}

模块联邦实现 🔗

// 1. 主应用配置
class ModuleFederationHost {static createConfig() {const deps = require('./package.json').dependencies;return {plugins: [new ModuleFederationPlugin({name: 'host',filename: 'remoteEntry.js',remotes: {app1: 'app1@http://localhost:3001/remoteEntry.js',app2: 'app2@http://localhost:3002/remoteEntry.js'},shared: {...deps,react: {singleton: true,requiredVersion: deps.react},'react-dom': {singleton: true,requiredVersion: deps['react-dom']}}})]};}static importRemoteModule() {return `// 动态加载远程模块const RemoteButton = React.lazy(() => import('app1/Button'));const App = () => (<div><h1>Host Application</h1><React.Suspense fallback="Loading Button..."><RemoteButton /></React.Suspense></div>);`;}
}// 2. 微前端模块配置
class ModuleFederationRemote {static createConfig() {const deps = require('./package.json').dependencies;return {plugins: [new ModuleFederationPlugin({name: 'app1',filename: 'remoteEntry.js',exposes: {'./Button': './src/components/Button','./Header': './src/components/Header','./API': './src/services/api'},shared: {...deps,react: {singleton: true,requiredVersion: deps.react},'react-dom': {singleton: true,requiredVersion: deps['react-dom']}}})]};}
}// 3. 共享模块高级配置
class SharedModulesAdvanced {static createConfig() {return {shared: {react: {singleton: true,requiredVersion: '^17.0.0',eager: true,strictVersion: true},moment: {singleton: false,requiredVersion: false,version: false,shareScope: 'default'},lodash: {shareKey: 'lodash',singleton: true,requiredVersion: '^4.17.21',eager: false}}};}
}

性能优化技术 ⚡

// 1. Tree Shaking 优化
class TreeShakingOptimizer {static configurePackageJson() {return {name: "my-project",version: "1.0.0",sideEffects: ["*.css","*.scss","./src/some-side-effectful-file.js"]};}static configureWebpack() {return {mode: 'production',optimization: {usedExports: true,sideEffects: true,providedExports: true,concatenateModules: true, // 模块合并minimize: true}};}static properModuleExport() {return `// 良好的tree-shaking友好导出export const add = (a, b) => a + b;export const subtract = (a, b) => a - b;export const multiply = (a, b) => a * b;export const divide = (a, b) => a / b;// 不友好的导出方式/*const utils = {add: (a, b) => a + b,subtract: (a, b) => a - b,multiply: (a, b) => a * b,divide: (a, b) => a / b};export default utils;*/`;}
}// 2. 缓存优化
class CachingOptimizer {static configureWebpack() {return {output: {filename: '[name].[contenthash].js',path: path.resolve(__dirname, 'dist'),chunkFilename: '[name].[contenthash].chunk.js',assetModuleFilename: 'assets/[hash][ext][query]'},optimization: {moduleIds: 'deterministic',runtimeChunk: 'single',splitChunks: {cacheGroups: {vendor: {test: /[\\/]node_modules[\\/]/,name: 'vendors',chunks: 'all'}}}}};}static configureTerser() {return {optimization: {minimizer: [new TerserPlugin({terserOptions: {compress: {drop_console: true,drop_debugger: true},format: {comments: false}},extractComments: false,parallel: true,cache: true})]}};}
}// 3. 构建性能优化
class BuildPerformanceOptimizer {static configureWebpack() {return {cache: {type: 'filesystem',buildDependencies: {config: [__filename]}},snapshot: {managedPaths: [/^(.+?[\\/]node_modules[\\/])/],immutablePaths: [/node_modules/],buildDependencies: {timestamp: true}},watchOptions: {aggregateTimeout: 300,poll: 1000,ignored: /node_modules/},stats: {chunks: false,modules: false,children: false,assets: true}};}static configureBundleAnalyzer() {return `const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;module.exports = {plugins: [new BundleAnalyzerPlugin({analyzerMode: 'static',reportFilename: 'bundle-report.html',openAnalyzer: false,generateStatsFile: true,statsFilename: 'bundle-stats.json'})]};`;}
}

高级加载器和插件 🔌

// 1. 自定义加载器
class CustomLoader {static createMarkdownLoader() {return `module.exports = function(source) {// 使loader可缓存this.cacheable && this.cacheable();// 异步处理const callback = this.async();// 处理 markdown 转换为 HTMLconst html = convertMarkdownToHtml(source);// 转换为模块导出const code = \`import React from 'react';export default function MarkdownContent() {return React.createElement('div', {dangerouslySetInnerHTML: { __html: ${JSON.stringify(html)} }});}\`;// 返回结果callback(null, code);};function convertMarkdownToHtml(markdown) {// 实现markdown到html的转换// 这里可以使用库如marked或showdownreturn "HTML content";}`;}static configureLoader() {return {module: {rules: [{test: /\.md$/,use: ['babel-loader',path.resolve('./loaders/markdown-loader.js')]}]}};}
}// 2. 自定义插件
class CustomPlugin {static createFileSizePlugin() {return `class FileSizePlugin {constructor(options = {}) {this.options = {outputFile: options.outputFile || 'file-sizes.json',warn: options.warn || false,warnLimit: options.warnLimit || 250 * 1024 // 250KB};}apply(compiler) {compiler.hooks.emit.tapAsync('FileSizePlugin',(compilation, callback) => {// 收集所有生成的文件大小信息const fileSizes = {};let totalSize = 0;for (const filename in compilation.assets) {const size = compilation.assets[filename].size();fileSizes[filename] = this.formatSize(size);totalSize += size;// 警告大文件if (this.options.warn && size > this.options.warnLimit) {console.warn(\`⚠️ Large file: \${filename} (\${this.formatSize(size)})\`);}}// 添加总大小fileSizes['total'] = this.formatSize(totalSize);// 创建输出文件const content = JSON.stringify(fileSizes, null, 2);compilation.assets[this.options.outputFile] = {source: () => content,size: () => content.length};callback();});}formatSize(bytes) {if (bytes < 1024) {return bytes + ' bytes';} else if (bytes < 1024 * 1024) {return (bytes / 1024).toFixed(2) + ' KB';} else {return (bytes / (1024 * 1024)).toFixed(2) + ' MB';}}}module.exports = FileSizePlugin;`;}static configurePlugin() {return `const FileSizePlugin = require('./plugins/file-size-plugin');module.exports = {plugins: [new FileSizePlugin({outputFile: 'file-sizes.json',warn: true,warnLimit: 300 * 1024 // 300KB})]};`;}
}// 3. 环境特定配置
class EnvironmentConfig {static createWebpackEnvConfig() {return `const { merge } = require('webpack-merge');const commonConfig = require('./webpack.common');module.exports = (envVars) => {const { mode } = envVars;const envConfig = require(\`./webpack.\${mode}\`);return merge(commonConfig, envConfig);};`;}static createEnvFiles() {return {common: `const path = require('path');const HtmlWebpackPlugin = require('html-webpack-plugin');module.exports = {entry: './src/index.js',output: {path: path.resolve(__dirname, 'dist'),filename: '[name].[contenthash].js',clean: true},module: {rules: [{test: /\.js$/,use: 'babel-loader',exclude: /node_modules/}]},plugins: [new HtmlWebpackPlugin({template: './public/index.html'})]};`,development: `const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');module.exports = {mode: 'development',devtool: 'eval-cheap-module-source-map',devServer: {hot: true,port: 3000,historyApiFallback: true},plugins: [new ReactRefreshWebpackPlugin()]};`,production: `const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');const TerserPlugin = require('terser-webpack-plugin');module.exports = {mode: 'production',devtool: 'source-map',optimization: {minimizer: [new TerserPlugin(),new CssMinimizerPlugin()]},performance: {hints: 'warning',maxEntrypointSize: 512000,maxAssetSize: 512000}};`};}
}

Webpack 5 新特性 🚀

// 1. 资源模块
class AssetModules {static configureAssetModules() {return {module: {rules: [// 图片资源{test: /\.(png|jpg|jpeg|gif)$/i,type: 'asset',parser: {dataUrlCondition: {maxSize: 8 * 1024 // 8KB}},generator: {filename: 'images/[hash][ext][query]'}},// 字体资源{test: /\.(woff|woff2|eot|ttf|otf)$/i,type: 'asset/resource',generator: {filename: 'fonts/[hash][ext][query]'}},// SVG资源{test: /\.svg$/i,oneOf: [{// 针对SVG React组件resourceQuery: /react/,use: ['@svgr/webpack']},{// 普通SVG资源type: 'asset/resource',generator: {filename: 'icons/[hash][ext][query]'}}]}]}};}static assetUsageExample() {return `// 图片资源import logo from './assets/logo.png';document.getElementById('logo').src = logo;// SVG React组件import { ReactComponent as Logo } from './assets/logo.svg?react';function Header() {return <Logo width={50} height={50} />;}// 字体资源import './assets/fonts/opensans.woff2';`;}
}// 2. 持久缓存
class PersistentCache {static configureCache() {return {cache: {type: 'filesystem',version: '1.0',cacheDirectory: path.resolve(__dirname, '.temp_cache'),name: 'my-project-cache',buildDependencies: {config: [__filename]},compression: 'gzip'}};}static setupMaxAge() {return {cache: {type: 'filesystem',maxAge: 5184000000, // 60 days in millisecondsmaxMemoryGenerations: 1}};}
}// 3. 实验性功能
class ExperimentalFeatures {static enableExperiments() {return {experiments: {asyncWebAssembly: true,topLevelAwait: true,outputModule: true,lazyCompilation: {entries: false,imports: true}}};}static topLevelAwaitExample() {return `// 顶级 await(不需要包装在 async 函数中)const response = await fetch('https://api.example.com/data');const data = await response.json();export default data;`;}static webAssemblyExample() {return `// 异步WebAssembly加载async function loadWasm() {const wasm = await import('./module.wasm');return wasm;}// 使用loadWasm().then(module => {module.exports.someFunction();});`;}
}

Webpack分析与调试 🔍

// 1. 构建分析
class BuildAnalysis {static configureStatsPreset() {return {stats: {preset: 'errors-warnings',assets: true,colors: true,timings: true,performance: true,optimizationBailout: true}};}static configureAnalyzerPlugin() {return `const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');module.exports = {plugins: [new BundleAnalyzerPlugin({analyzerMode: process.env.ANALYZE ? 'server' : 'disabled',analyzerHost: '127.0.0.1',analyzerPort: 8888,reportFilename: 'bundle-report.html',openAnalyzer: true,generateStatsFile: true,statsFilename: 'stats.json',statsOptions: {source: false,reasons: true},excludeAssets: [/\.map$/]})]};`;}static configureSpeedMeasurePlugin() {return `const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');const smp = new SpeedMeasurePlugin();// 包装整个webpack配置module.exports = smp.wrap({// 常规webpack配置...});`;}
}// 2. 调试技巧
class WebpackDebugging {static profileConfig() {return `module.exports = {// ...其他配置profile: true};`;}static traceConfig() {return `// 命令行使用示例// webpack --trace-deprecation// webpack --trace-warnings// webpack --trace`;}static inspectConfig() {return `// 检查配置const { inspect } = require('util');module.exports = (env, argv) => {const config = {// ...正常配置};// 输出最终配置到控制台console.log(inspect(config, { depth: null, colors: true }));return config;};`;}
}

高级优化策略 💎

// 1. 懒加载优化
class LazyLoadingOptimization {static routeLevelCodeSplitting() {return `// React Router 懒加载import React, { lazy, Suspense } from 'react';import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';// 懒加载路由组件const Home = lazy(() => import(/* webpackChunkName: "home" */ './pages/Home'));const About = lazy(() => import(/* webpackChunkName: "about" */ './pages/About'));const Dashboard = lazy(() => import(/* webpackChunkName: "dashboard" */ './pages/Dashboard'));function App() {return (<Router><Suspense fallback={<div>Loading...</div>}><Switch><Route exact path="/" component={Home} /><Route path="/about" component={About} /><Route path="/dashboard" component={Dashboard} /></Switch></Suspense></Router>);}`;}static componentLevelCodeSplitting() {return `// 组件级懒加载import React, { lazy, Suspense, useState } from 'react';// 懒加载重型组件const HeavyChart = lazy(() => import(/* webpackChunkName: "heavy-chart" */ './components/HeavyChart'));function Dashboard() {const [showChart, setShowChart] = useState(false);return (<div><h1>Dashboard</h1><button onClick={() => setShowChart(true)}>Load Chart</button>{showChart && (<Suspense fallback={<div>Loading chart...</div>}><HeavyChart /></Suspense>)}</div>);}`;}
}// 2. 线上部署优化
class DeploymentOptimization {static configureOutput() {return {output: {filename: '[name].[contenthash].js',chunkFilename: '[name].[contenthash].chunk.js',path: path.resolve(__dirname, 'dist'),publicPath: 'https://cdn.example.com/',crossOriginLoading: 'anonymous'}};}static configureSecurity() {return {output: {trustedTypes: true,crossOriginLoading: 'anonymous'},devtool: false, // 生产环境禁用源代码映射plugins: [new webpack.ids.HashedModuleIdsPlugin(), // 稳定模块IDnew webpack.DefinePlugin({'process.env.NODE_ENV': JSON.stringify('production'),'process.env.API_URL': JSON.stringify('https://api.example.com')})]};}static configureCompression() {return `const CompressionPlugin = require('compression-webpack-plugin');const zlib = require('zlib');module.exports = {plugins: [// Gzip压缩new CompressionPlugin({filename: '[path][base].gz',algorithm: 'gzip',test: /\.(js|css|html|svg)$/,threshold: 10240, // 只处理大于10KB的资源minRatio: 0.8 // 只有压缩率小于0.8的资源才会被处理}),// Brotli压缩(更高压缩率)new CompressionPlugin({filename: '[path][base].br',algorithm: 'brotliCompress',test: /\.(js|css|html|svg)$/,compressionOptions: {params: {[zlib.constants.BROTLI_PARAM_QUALITY]: 11}},threshold: 10240,minRatio: 0.8})]};`;}
}

结语 📝

Webpack的高级配置能够帮助我们构建更高效、更优化的前端应用。我们学习了:

  1. 代码分割策略和动态导入
  2. 模块联邦实现微前端架构
  3. 性能优化技术如Tree Shaking和缓存优化
  4. 自定义加载器和插件开发
  5. Webpack 5的新特性
  6. 构建分析与调试技巧
  7. 高级优化策略和部署配置

💡 学习建议:

  1. 逐步应用这些高级特性,不要一次性应用所有优化
  2. 使用分析工具监控优化效果
  3. 根据项目需求选择合适的配置
  4. 持续关注Webpack的更新和新特性
  5. 参考成熟项目的Webpack配置学习最佳实践

如果你觉得这篇文章有帮助,欢迎点赞收藏,也期待在评论区看到你的想法和建议!👇

终身学习,共同成长。

咱们下一期见

💻

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/24413.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

2025面试Go真题第一场

前几天参加了一场面试&#xff0c;GoLang 后端工程师&#xff0c;他们直接给了我 10 道题&#xff0c;我留了一个截图。 在看答案之前&#xff0c;你可以先简单做一下&#xff0c;下面我会对每个题目做一个说明。 文章目录 1、golang map 是否并发安全?2、协程泄漏的原因可能是…

网络安全第三次练习

一、实验拓扑 二、实验要求 配置真实DNS服务信息&#xff0c;创建虚拟服务&#xff0c;配置DNS透明代理功能 三、需求分析 1.创建用户并配置认证策略 2.安全策略划分接口 3.ip与策略配置 四、实验步骤 1.划分安全策略接口 2.创建用户并进行策略认证 3.配置安全策略 4.NAT配…

FTP 实验(ENSP模拟器实现)

目录 FTP 概述 FTP实验 FTP的报文交互 FTP 概述 FTP&#xff08;File Transfer Protocol&#xff0c;文件传输协议&#xff09;是一种用于在网络上进行文件传输的标准协议。它允许用户在两台计算机之间上传和下载文件。 1、FTP采用客户端-服务器模型&#xff0c;客户端通过…

Elasticsearch:使用经过训练的 ML 模型理解稀疏向量嵌入

作者&#xff1a;来自 Elastic Dai Sugimori 了解稀疏向量嵌入&#xff0c;理解它们的作用/含义&#xff0c;以及如何使用它们实现语义搜索。 Elasticsearch 提供语义搜索功能&#xff0c;允许用户使用自然语言进行查询并检索相关信息。为此&#xff0c;目标文档和查询必须首先…

Java进阶(vue基础)

目录 1.vue简单入门 ?1.1.创建一个vue程序 1.2.使用Component模板(组件&#xff09; 1.3.引入AXOIS ?1.4.vue的Methods&#xff08;方法&#xff09; 和?compoted&#xff08;计算&#xff09; 1.5.插槽slot 1.6.创建自定义事件? 2.Vue脚手架安装? 3.Element-UI的…

密码学基础

第1节 密码学概述 密码是人类在信息活动中的一项伟大发明&#xff0c;是保护秘密信息的工具。它诞生于公元前两千余年的埃及&#xff0c;迄今已有四千多年的历史。在出现年代有可查证记录的科学技术中&#xff0c;密码是历史最为悠久的科学技术之一。 百度百科里对密码的解释&…

Java入门级小案例:网页版简易计算器

网页版简易计算器 目录 网页版简易计算器需求&#xff1a;代码实现&#xff1a;效果显示 需求&#xff1a; 用HTML、CSS、JS进行书写一个具备一定功能的简易计算器。 代码实现&#xff1a; <!DOCTYPE html> <html lang"en"> <head><meta cha…

【Uniapp-Vue3】导入uni-id用户体系

在uniapp官网的uniCloud中下载uni-id用户体系 或者直接进入加载&#xff0c;下载地址&#xff1a;uni-id-pages - DCloud 插件市场 进入以后下载插件&#xff0c;打开HbuilderX 选中项目&#xff0c;点击确定 点击跳过 点击合并 右键uniCloud文件夹下的database文件夹&#x…

Python 入门教程(2)搭建环境 | 2.3、VSCode配置Python开发环境

文章目录 一、VSCode配置Python开发环境1、软件安装2、安装Python插件3、配置Python环境4、包管理5、调试程序 前言 Visual Studio Code&#xff08;简称VSCode&#xff09;以其强大的功能和灵活的扩展性&#xff0c;成为了许多开发者的首选。本文将详细介绍如何在VSCode中配置…

Spring Boot电影评论网站系统设计与实现

随着互联网和娱乐产业的发展&#xff0c;电影评论网站逐渐成为人们分享观影体验、交流影评的重要平台。本文将介绍一个基于Spring Boot框架开发的电影评论网站系统的功能设计与实现方案。 功能模块概述 该电影评论网站系统分为管理员模块和用户模块两大核心部分&#xff0c;以…

RT-Thread+STM32L475VET6——TF 卡文件系统

文章目录 前言一、板载资源二、具体步骤1.打开CubeMX进行USB配置1.1 使用外部高速时钟&#xff0c;并修改时钟树1.2 打开SPI1&#xff0c;参数默认即可(SPI根据自己需求调整&#xff09;1.3 打开串口&#xff0c;参数默认1.4 生成工程 2.配置SPI2.1 打开SPI驱动2.2 声明使用SPI…

LabVIEW形状误差测量系统

在机械制造领域&#xff0c;形状与位置公差&#xff08;GD&T&#xff09;直接影响装配精度与产品寿命。国内中小型机加工企业因形状误差导致的返工率高达12%-18%。传统测量方式存在以下三大痛点&#xff1a; ​ 设备局限&#xff1a;机械式千分表需人工读数&#xff0c;精度…

【c语言】字符函数和字符串函数(1)

一、字符分类函数 c语言中有部分函数是专门做字符分类的&#xff0c;也就是一个字符是属于什么类型的字符&#xff0c;这些函 数的使用要包含一个头文件ctype.h中。 其具体如下图所示&#xff1a; 这些函数的使用方式都类似&#xff0c;下面我们通过一个函数来看其…

【Python LeetCode 专题】动态规划

斐波那契类型70. 爬楼梯746. 使用最小花费爬楼梯198. 打家劫舍740. 删除并获得点数矩阵62. 不同路径方法一:二维 DP方法二:递归(`@cache`)64. 最小路径和63. 不同路径 II120. 三角形最小路径和221. 最大正方形字符串139. 单词拆分5. 最长回文子串516. 最长回文子序列72. 编…

Linux相关知识(文件系统、目录树、权限管理)和Shell相关知识(字符串、数组)

仅供自学&#xff0c;请去支持javaGuide原版书籍。 1.Linux 1.1.概述 Linux是一种类Unix系统。 严格来讲&#xff0c;Linux 这个词本身只表示 Linux内核&#xff0c;单独的 Linux 内核并不能成为一个可以正常工作的操作系统。所以&#xff0c;就有了各种 Linux 发行版&#…

第九节: Vue 3 中的 provide 与 inject:优雅的跨组件通信

文章目录 前言什么是 provide 和 inject&#xff1f;provide 的基本使用inject 的基本使用provide 提供响应式数据数据provide 提供修改数据的方法provide 提供只读响应数据provide 使用symbol作为注入名inject 默认值总结 前言 在 Vue 3 中&#xff0c;provide 和 inject 是一…

prometheus+node_exporter+grafana监控K8S信息

prometheusnode_exportergrafana监控K8S 1.prometheus部署2.node_exporter部署3.修改prometheus配置文件4.grafana部署 1.prometheus部署 包下载地址&#xff1a;https://prometheus.io/download/ 将包传至/opt 解压 tar xf prometheus-2.53.3.linux-amd64.tar.gz 移动到…

C/C++流星雨

系列文章 序号直达链接1C/C李峋同款跳动的爱心2C/C跳动的爱心3C/C经典爱心4C/C满屏飘字5C/C大雪纷飞6C/C炫酷烟花7C/C黑客帝国同款字母雨8C/C樱花树9C/C奥特曼10C/C精美圣诞树11C/C俄罗斯方块小游戏12C/C贪吃蛇小游戏13C/C孤单又灿烂的神14C/C闪烁的爱心15C/C哆啦A梦16C/C简单…

理解 MHA、GQA、MQA 和 MLA:多头注意力的变种及其应用

在深度学习、自然语言处理&#xff08;NLP&#xff09;和计算机视觉&#xff08;CV&#xff09;中&#xff0c;多头注意力&#xff08;Multi-Head Attention, MHA&#xff09;是 Transformer 结构的核心。近年来&#xff0c;MHA 产生了多个变体&#xff0c;如 GQA&#xff08;G…

Crack SmartGit

感谢大佬提供的资源 一、正常安装SmartGit 二、下载crackSmartGit crackSmartGit 发行版 - Gitee.com 三、使用crackSmartGit 1. 打开用户目录&#xff1a;C:\Users%用户名%\AppData\Roaming\syntevo\SmartGit。将crackSmartGit.jar和license.zip拷贝至 用户目录。 2. 用户…