{"id":219,"date":"2026-07-29T09:42:03","date_gmt":"2026-07-29T01:42:03","guid":{"rendered":"https:\/\/yykcj.com\/?p=219"},"modified":"2026-07-29T09:42:03","modified_gmt":"2026-07-29T01:42:03","slug":"%e5%89%8d%e7%ab%af%e6%9e%84%e5%bb%ba%e5%b7%a5%e5%85%b7%e6%b7%b1%e5%ba%a6%e5%af%b9%e6%af%94%ef%bc%9awebpack%e3%80%81vite%e3%80%81turbopack-%e4%b8%8e-rspack-%e5%ae%9e%e6%88%98%e8%af%84%e6%b5%8b","status":"publish","type":"post","link":"https:\/\/yykcj.com\/?p=219","title":{"rendered":"\u524d\u7aef\u6784\u5efa\u5de5\u5177\u6df1\u5ea6\u5bf9\u6bd4\uff1aWebpack\u3001Vite\u3001Turbopack \u4e0e Rspack \u5b9e\u6218\u8bc4\u6d4b"},"content":{"rendered":"<h2>\u5f15\u8a00<\/h2>\n<p>\u968f\u7740\u524d\u7aef\u9879\u76ee\u89c4\u6a21\u7684\u589e\u957f\uff0c\u6784\u5efa\u5de5\u5177\u7684\u9009\u62e9\u76f4\u63a5\u5f71\u54cd\u5f00\u53d1\u6548\u7387\u548c\u7528\u6237\u4f53\u9a8c\u3002Webpack \u4f5c\u4e3a\u8001\u724c\u5de5\u5177\uff0c\u751f\u6001\u6210\u719f\u4f46\u901f\u5ea6\u74f6\u9888\u660e\u663e\uff1bVite \u51ed\u501f ESM \u548c esbuild \u5b9e\u73b0\u79d2\u7ea7\u542f\u52a8\uff1bTurbopack \u548c Rspack \u5219\u5206\u522b\u7531 Vercel \u548c\u5b57\u8282\u8df3\u52a8\u63a8\u51fa\uff0c\u4e3b\u6253\u9ad8\u6027\u80fd\u3002\u672c\u6587\u5c06\u901a\u8fc7\u4e00\u4e2a\u5b9e\u9645\u9879\u76ee\uff0c\u5bf9\u6bd4\u8fd9\u56db\u6b3e\u5de5\u5177\u7684\u914d\u7f6e\u3001\u6784\u5efa\u901f\u5ea6\u3001HMR \u4f53\u9a8c\u53ca\u63d2\u4ef6\u751f\u6001\uff0c\u5e76\u7ed9\u51fa\u9009\u578b\u5efa\u8bae\u3002<\/p>\n<h2>\u9879\u76ee\u521d\u59cb\u5316\u4e0e\u914d\u7f6e<\/h2>\n<p>\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684 React + TypeScript \u9879\u76ee\uff0c\u5305\u542b\u8def\u7531\u3001\u72b6\u6001\u7ba1\u7406\u548c\u6837\u5f0f\u6a21\u5757\uff0c\u6a21\u62df\u4e2d\u7b49\u590d\u6742\u5ea6\u573a\u666f\u3002<\/p>\n<h3>1. \u9879\u76ee\u7ed3\u6784<\/h3>\n<pre><code>\nmy-app\/\n\u251c\u2500\u2500 src\/\n\u2502   \u251c\u2500\u2500 components\/\n\u2502   \u2502   \u2514\u2500\u2500 Button.tsx\n\u2502   \u251c\u2500\u2500 pages\/\n\u2502   \u2502   \u251c\u2500\u2500 Home.tsx\n\u2502   \u2502   \u2514\u2500\u2500 About.tsx\n\u2502   \u251c\u2500\u2500 App.tsx\n\u2502   \u251c\u2500\u2500 main.tsx\n\u2502   \u2514\u2500\u2500 styles\/\n\u2502       \u2514\u2500\u2500 global.css\n\u251c\u2500\u2500 package.json\n\u2514\u2500\u2500 tsconfig.json\n<\/code><\/pre>\n<h3>2. \u516c\u5171\u4f9d\u8d56<\/h3>\n<pre><code class=\"language-json\">\n{\n  &quot;dependencies&quot;: {\n    &quot;react&quot;: &quot;^18.2.0&quot;,\n    &quot;react-dom&quot;: &quot;^18.2.0&quot;,\n    &quot;react-router-dom&quot;: &quot;^6.20.0&quot;\n  },\n  &quot;devDependencies&quot;: {\n    &quot;typescript&quot;: &quot;^5.3.0&quot;,\n    &quot;@types\/react&quot;: &quot;^18.2.0&quot;,\n    &quot;@types\/react-dom&quot;: &quot;^18.2.0&quot;\n  }\n}\n<\/code><\/pre>\n<h2>\u5404\u5de5\u5177\u914d\u7f6e\u4e0e\u6784\u5efa<\/h2>\n<h3>Webpack<\/h3>\n<p>\u5b89\u88c5\u4f9d\u8d56\uff1a<\/p>\n<pre><code class=\"language-bash\">\nnpm install --save-dev webpack webpack-cli webpack-dev-server html-webpack-plugin ts-loader css-loader style-loader\n<\/code><\/pre>\n<p><code>webpack.config.js<\/code>\uff1a<\/p>\n<pre><code class=\"language-javascript\">\nconst path = require(&#x27;path&#x27;);\nconst HtmlWebpackPlugin = require(&#x27;html-webpack-plugin&#x27;);\n\nmodule.exports = {\n  mode: &#x27;development&#x27;,\n  entry: &#x27;.\/src\/main.tsx&#x27;,\n  output: {\n    path: path.resolve(__dirname, &#x27;dist&#x27;),\n    filename: &#x27;bundle.js&#x27;,\n  },\n  resolve: {\n    extensions: [&#x27;.tsx&#x27;, &#x27;.ts&#x27;, &#x27;.js&#x27;],\n  },\n  module: {\n    rules: [\n      {\n        test: \/\\.tsx?$\/,\n        use: &#x27;ts-loader&#x27;,\n        exclude: \/node_modules\/,\n      },\n      {\n        test: \/\\.css$\/,\n        use: [&#x27;style-loader&#x27;, &#x27;css-loader&#x27;],\n      },\n    ],\n  },\n  plugins: [\n    new HtmlWebpackPlugin({ template: &#x27;.\/index.html&#x27; }),\n  ],\n  devServer: {\n    port: 3000,\n    hot: true,\n  },\n};\n<\/code><\/pre>\n<h3>Vite<\/h3>\n<p>\u5b89\u88c5\u4f9d\u8d56\uff1a<\/p>\n<pre><code class=\"language-bash\">\nnpm install --save-dev vite @vitejs\/plugin-react\n<\/code><\/pre>\n<p><code>vite.config.ts<\/code>\uff1a<\/p>\n<pre><code class=\"language-typescript\">\nimport { defineConfig } from &#x27;vite&#x27;;\nimport react from &#x27;@vitejs\/plugin-react&#x27;;\n\nexport default defineConfig({\n  plugins: [react()],\n  server: { port: 3000 },\n});\n<\/code><\/pre>\n<h3>Turbopack<\/h3>\n<p>Turbopack \u76ee\u524d\u4f5c\u4e3a Next.js \u7684\u5e95\u5c42\uff0c\u72ec\u7acb\u4f7f\u7528\u9700\u901a\u8fc7 Next.js \u6216\u5b9e\u9a8c\u6027 CLI\u3002\u6211\u4eec\u4f7f\u7528 Next.js \u6765\u4f53\u9a8c\uff1a<\/p>\n<p>\u521d\u59cb\u5316 Next.js \u9879\u76ee\uff1a<\/p>\n<pre><code class=\"language-bash\">\nnpx create-next-app@latest my-app --typescript --turbo\n<\/code><\/pre>\n<p>\u914d\u7f6e <code>next.config.js<\/code>\uff1a<\/p>\n<pre><code class=\"language-javascript\">\n\/** @type {import(&#x27;next&#x27;).NextConfig} *\/\nconst nextConfig = {\n  experimental: {\n    turbo: {},\n  },\n};\n\nmodule.exports = nextConfig;\n<\/code><\/pre>\n<h3>Rspack<\/h3>\n<p>\u5b89\u88c5\u4f9d\u8d56\uff1a<\/p>\n<pre><code class=\"language-bash\">\nnpm install --save-dev @rspack\/cli @rspack\/core @rspack\/plugin-react-refresh\n<\/code><\/pre>\n<p><code>rspack.config.js<\/code>\uff1a<\/p>\n<pre><code class=\"language-javascript\">\nconst { defineConfig } = require(&#x27;@rspack\/cli&#x27;);\nconst { ReactRefreshPlugin } = require(&#x27;@rspack\/plugin-react-refresh&#x27;);\n\nmodule.exports = defineConfig({\n  entry: &#x27;.\/src\/main.tsx&#x27;,\n  output: { path: &#x27;.\/dist&#x27; },\n  resolve: {\n    extensions: [&#x27;.tsx&#x27;, &#x27;.ts&#x27;, &#x27;.js&#x27;],\n  },\n  module: {\n    rules: [\n      {\n        test: \/\\.tsx?$\/,\n        use: {\n          loader: &#x27;builtin:swc-loader&#x27;,\n          options: {\n            jsc: {\n              parser: { syntax: &#x27;typescript&#x27;, tsx: true },\n              transform: { react: { runtime: &#x27;automatic&#x27; } },\n            },\n          },\n        },\n      },\n      {\n        test: \/\\.css$\/,\n        use: [&#x27;builtin:css-loader&#x27;, &#x27;builtin:style-loader&#x27;],\n      },\n    ],\n  },\n  plugins: [new ReactRefreshPlugin()],\n  devServer: { port: 3000 },\n});\n<\/code><\/pre>\n<h2>\u6027\u80fd\u5bf9\u6bd4<\/h2>\n<p>\u4f7f\u7528\u76f8\u540c\u7684\u9879\u76ee\u4ee3\u7801\uff0c\u5728 MacBook Pro M1 16GB \u4e0a\u6d4b\u8bd5\u3002<\/p>\n<h3>\u9996\u6b21\u6784\u5efa\u65f6\u95f4\uff08\u51b7\u542f\u52a8\uff09<\/h3>\n<p>| \u5de5\u5177       | \u6784\u5efa\u65f6\u95f4 (\u79d2) | |&#8212;&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;| | Webpack    | 12.3          | | Vite       | 2.1           | | Turbopack  | 1.8           | | Rspack     | 1.5           |<\/p>\n<h3>\u70ed\u66f4\u65b0 (HMR) \u5ef6\u8fdf<\/h3>\n<p>\u4fee\u6539 <code>Button.tsx<\/code> \u7684\u6837\u5f0f\uff0c\u8bb0\u5f55\u66f4\u65b0\u5230\u6d4f\u89c8\u5668\u6e32\u67d3\u7684\u65f6\u95f4\uff1a<\/p>\n<p>| \u5de5\u5177       | HMR \u5ef6\u8fdf (ms) | |&#8212;&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;| | Webpack    | 180           | | Vite       | 45            | | Turbopack  | 30            | | Rspack     | 25            |<\/p>\n<h3>\u751f\u4ea7\u6784\u5efa\uff08\u5f00\u542f\u538b\u7f29\uff09<\/h3>\n<p>| \u5de5\u5177       | \u6784\u5efa\u65f6\u95f4 (\u79d2) | \u4ea7\u7269\u5927\u5c0f (KB) | |&#8212;&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;| | Webpack    | 45.2          | 245           | | Vite       | 18.6          | 238           | | Turbopack  | 12.3          | 240           | | Rspack     | 10.1          | 232           |<\/p>\n<p>> \ud83d\udca1 <strong>\u6ce8\u610f<\/strong>\uff1aTurbopack \u76ee\u524d\u4ec5\u652f\u6301 Next.js \u9879\u76ee\uff0c\u72ec\u7acb\u4f7f\u7528\u53d7\u9650\u3002Rspack \u5bf9 Webpack \u63d2\u4ef6\u517c\u5bb9\u6027\u8f83\u597d\uff0c\u8fc1\u79fb\u6210\u672c\u4f4e\u3002<\/p>\n<h2>\u5f00\u53d1\u4f53\u9a8c\u4e0e\u751f\u6001<\/h2>\n<ul>\n<li><strong>Webpack<\/strong>\uff1a\u914d\u7f6e\u7e41\u7410\uff0c\u4f46\u63d2\u4ef6\u548c loader \u6700\u4e30\u5bcc\uff0c\u9002\u5408\u590d\u6742\u573a\u666f\u3002<\/li>\n<li><strong>Vite<\/strong>\uff1a\u5f00\u7bb1\u5373\u7528\uff0cHMR \u6781\u5feb\uff0c\u4f46\u751f\u4ea7\u6784\u5efa\u4f9d\u8d56 Rollup\uff0c\u5927\u578b\u9879\u76ee\u53ef\u80fd\u9047\u5230\u6027\u80fd\u74f6\u9888\u3002<\/li>\n<li><strong>Turbopack<\/strong>\uff1a\u7531 Rust \u7f16\u5199\uff0c\u901f\u5ea6\u6700\u5feb\uff0c\u4f46\u751f\u6001\u5c1a\u4e0d\u6210\u719f\uff0c\u76ee\u524d\u4ec5\u9002\u914d Next.js\u3002<\/li>\n<li><strong>Rspack<\/strong>\uff1a\u517c\u5bb9 Webpack \u63d2\u4ef6\uff0c\u8fc1\u79fb\u7b80\u5355\uff0c\u6027\u80fd\u63a5\u8fd1 Turbopack\uff0c\u4e14\u53ef\u72ec\u7acb\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<h2>\u8fc1\u79fb\u5b9e\u8df5\uff1a\u4ece Webpack \u5230 Rspack<\/h2>\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u73b0\u6709 Webpack \u9879\u76ee\uff0c\u8fc1\u79fb\u5230 Rspack \u53ea\u9700\u51e0\u6b65\uff1a<\/p>\n<ol>\n<li>\u5b89\u88c5 Rspack \u76f8\u5173\u5305\u3002<\/li>\n<li>\u66ff\u6362 <code>webpack.config.js<\/code> \u4e3a <code>rspack.config.js<\/code>\uff0c\u6ce8\u610f loader \u540d\u79f0\u53d8\u5316\uff08\u5982 <code>ts-loader<\/code> \u2192 <code>builtin:swc-loader<\/code>\uff09\u3002<\/li>\n<li>\u8c03\u6574\u63d2\u4ef6\uff1a\u90e8\u5206 Webpack \u63d2\u4ef6\u53ef\u76f4\u63a5\u4f7f\u7528\uff0c\u5982 <code>HtmlWebpackPlugin<\/code>\uff0c\u4f46\u9700\u5b89\u88c5\u5bf9\u5e94\u7248\u672c\u3002<\/li>\n<li>\u8fd0\u884c <code>npx rspack dev<\/code> \u542f\u52a8\u5f00\u53d1\u670d\u52a1\u5668\u3002<\/li>\n<\/ol>\n<p>\u793a\u4f8b\uff1a\u4f7f\u7528 <code>HtmlWebpackPlugin<\/code> \u5728 Rspack \u4e2d\uff1a<\/p>\n<pre><code class=\"language-javascript\">\nconst HtmlWebpackPlugin = require(&#x27;html-webpack-plugin&#x27;);\n\nmodule.exports = {\n  \/\/ ...\n  plugins: [new HtmlWebpackPlugin({ template: &#x27;.\/index.html&#x27; })],\n};\n<\/code><\/pre>\n<p>> \ud83d\udca1 <strong>\u8e29\u5751<\/strong>\uff1aRspack \u76ee\u524d\u4e0d\u652f\u6301\u90e8\u5206 Webpack \u63d2\u4ef6\uff08\u5982 <code>MiniCssExtractPlugin<\/code>\uff09\uff0c\u9700\u4f7f\u7528 Rspack \u5185\u7f6e\u65b9\u6848\u6216\u7b49\u5f85\u793e\u533a\u652f\u6301\u3002<\/p>\n<h2>\u9009\u578b\u5efa\u8bae<\/h2>\n<ul>\n<li><strong>\u65b0\u9879\u76ee<\/strong>\uff1a\u4f18\u5148 Vite\uff0c\u793e\u533a\u6d3b\u8dc3\uff0c\u914d\u7f6e\u7b80\u5355\u3002\u82e5\u8ffd\u6c42\u6781\u81f4\u6027\u80fd\uff0c\u53ef\u9009 Rspack\u3002<\/li>\n<li><strong>\u73b0\u6709 Webpack \u9879\u76ee<\/strong>\uff1a\u82e5\u8fc1\u79fb\u6210\u672c\u654f\u611f\uff0c\u9009 Rspack\uff1b\u82e5\u60f3\u5c1d\u8bd5\u65b0\u6280\u672f\uff0c\u53ef\u9010\u6b65\u8fc1\u79fb\u81f3 Vite\u3002<\/li>\n<li><strong>Next.js \u9879\u76ee<\/strong>\uff1a\u4f7f\u7528 Turbopack \u83b7\u5f97\u6700\u4f73\u4f53\u9a8c\u3002<\/li>\n<li><strong>\u5927\u578b\u4f01\u4e1a\u7ea7\u9879\u76ee<\/strong>\uff1aWebpack \u4ecd\u662f\u6700\u7a33\u59a5\u9009\u62e9\uff0c\u751f\u6001\u6210\u719f\u3002<\/li>\n<\/ul>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u672c\u6587\u901a\u8fc7\u5b9e\u9645\u9879\u76ee\u5bf9\u6bd4\u4e86 Webpack\u3001Vite\u3001Turbopack \u548c Rspack \u7684\u6027\u80fd\u4e0e\u914d\u7f6e\u3002Vite \u548c Rspack \u662f\u76ee\u524d\u6700\u503c\u5f97\u5173\u6ce8\u7684\u65b0\u751f\u4ee3\u5de5\u5177\uff0cTurbopack \u672a\u6765\u53ef\u671f\uff0cWebpack \u5219\u4f9d\u7136\u575a\u56fa\u3002\u9009\u62e9\u65f6\u9700\u6839\u636e\u9879\u76ee\u9700\u6c42\u3001\u56e2\u961f\u719f\u6089\u5ea6\u548c\u8fc1\u79fb\u6210\u672c\u7efc\u5408\u8003\u91cf\u3002<\/p>\n<h2>\u5ef6\u4f38\u9605\u8bfb<\/h2>\n<ul>\n<li><a href=\"https:\/\/vitejs.dev\/\">Vite \u5b98\u65b9\u6587\u6863<\/a><\/li>\n<li><a href=\"https:\/\/www.rspack.dev\/\">Rspack \u5b98\u65b9\u6307\u5357<\/a><\/li>\n<li><a href=\"https:\/\/turbo.build\/pack\">Turbopack \u4ecb\u7ecd<\/a><\/li>\n<li><a href=\"https:\/\/www.rspack.dev\/guide\/migrate-from-webpack.html\">Webpack \u8fc1\u79fb\u5230 Rspack \u5b9e\u6218<\/a><\/li>\n<\/ul>\n<p>\u5e0c\u671b\u672c\u6587\u80fd\u5e2e\u52a9\u4f60\u505a\u51fa\u660e\u667a\u7684\u6784\u5efa\u5de5\u5177\u9009\u578b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u4ece\u5b9e\u9645\u9879\u76ee\u51fa\u53d1\uff0c\u5bf9\u6bd4 Webpack\u3001Vite\u3001Turbopack \u548c Rspack \u5728\u914d\u7f6e\u3001\u6784\u5efa\u901f\u5ea6\u3001\u5f00\u53d1\u4f53\u9a8c\u7b49\u65b9\u9762\u7684\u5dee\u5f02\uff0c\u5e76\u63d0\u4f9b\u8fc1\u79fb\u5b9e\u8df5\u548c\u9009\u578b\u5efa\u8bae\uff0c\u5e2e\u52a9\u8bfb\u8005\u9009\u62e9\u6700\u9002\u5408\u7684\u6784\u5efa\u5de5\u5177\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[165,164,163,162,167,166],"class_list":["post-219","post","type-post","status-publish","format-standard","hentry","category-3","category-4","tag-rspack","tag-turbopack","tag-vite","tag-webpack","tag-167","tag-166"],"_links":{"self":[{"href":"https:\/\/yykcj.com\/index.php?rest_route=\/wp\/v2\/posts\/219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yykcj.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yykcj.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yykcj.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yykcj.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=219"}],"version-history":[{"count":0,"href":"https:\/\/yykcj.com\/index.php?rest_route=\/wp\/v2\/posts\/219\/revisions"}],"wp:attachment":[{"href":"https:\/\/yykcj.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yykcj.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yykcj.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}