{"id":10020612,"date":"2025-01-11T15:06:35","date_gmt":"2025-01-11T07:06:35","guid":{"rendered":"https:\/\/itmax.cn\/?p=10020612"},"modified":"2025-01-11T15:06:35","modified_gmt":"2025-01-11T07:06:35","slug":"%e5%bc%80%e5%8f%91%e5%b0%8f%e7%a8%8b%e5%ba%8f%e5%8f%88%e4%b8%80%e6%96%b0%e9%80%89%e6%8b%a9-vue-mini%ef%bc%8c%e6%8d%ae%e8%af%b4%e6%80%a7%e8%83%bd%e6%98%af-taro-%e7%9a%84-10-%e5%80%8d%ef%bc%8c%e9%81%a5","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10020612","title":{"rendered":"\u5f00\u53d1\u5c0f\u7a0b\u5e8f\u53c8\u4e00\u65b0\u9009\u62e9 vue-mini\uff0c\u636e\u8bf4\u6027\u80fd\u662f Taro \u7684 10 \u500d\uff0c\u9065\u9065\u9886\u5148"},"content":{"rendered":"<h2>1. \u524d\u8a00<\/h2>\n<p>\u5927\u5bb6\u597d\uff0c\u6211\u662f<a href=\"https:\/\/link.segmentfault.com\/?enc=NszJTtrGBrhtgQX3iOxkLw%3D%3D.fakWpuHEMqnGSRuePxQvg5jYc3tXfasedTyUH%2BWX%2F8E%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u82e5\u5ddd<\/a>\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684<a href=\"https:\/\/link.segmentfault.com\/?enc=uBCD9y%2FGCWOM6z1hqUZHqA%3D%3D.8E466UUk4T8mGNyorjx9Jp2th%2FBczmmJ8Wov4HCU8QSD%2FEPreZfQ9kcJjGHerBCQdaYal35CRXxD8p3Kj0YvSw%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u516c\u4f17\u53f7\uff1a\u82e5\u5ddd\u89c6\u91ce<\/a>\u3002\u6211\u503e\u529b\u6301\u7eed\u7ec4\u7ec7\u4e86 3 \u5e74\u591a<a href=\"https:\/\/link.segmentfault.com\/?enc=asZ6aBlhP%2BpUJVdptTTFqg%3D%3D.CsrnRmcZkToiYoRlxx6z7VbLBX2XAUAL9u1kAbICiSi5mAFPfB4Zm0ulEP2XYZTC\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u6bcf\u5468\u5927\u5bb6\u4e00\u8d77\u5b66\u4e60 200 \u884c\u5de6\u53f3\u7684\u6e90\u7801\u5171\u8bfb\u6d3b\u52a8<\/a>\uff0c\u611f\u5174\u8da3\u7684\u53ef\u4ee5<a href=\"https:\/\/link.segmentfault.com\/?enc=UuRa%2FItuvhWy%2BeytLpY1Kw%3D%3D.N9I2jUDKsR%2BvYDdpJww9RSvevmzkkgDnuXOxifnyjRD2KUxfpGpj3XS3zvfU08l5\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u70b9\u6b64\u626b\u7801\u52a0\u6211\u5fae\u4fe1 <code>ruochuan02<\/code> \u53c2\u4e0e<\/a>\u3002\u53e6\u5916\uff0c\u60f3\u5b66\u6e90\u7801\uff0c\u6781\u529b\u63a8\u8350\u5173\u6ce8\u6211\u5199\u7684\u4e13\u680f<a href=\"https:\/\/link.segmentfault.com\/?enc=CSlegCGm7jkZv7wDEE7duQ%3D%3D.Abf%2F1FkniETjesajgw%2BmBzHAaShsCw3uxUMP%2FxElj%2FtHNfliXlg7WICGVWzfLngJ\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u300a\u5b66\u4e60\u6e90\u7801\u6574\u4f53\u67b6\u6784\u7cfb\u5217\u300b<\/a>\uff0c\u76ee\u524d\u662f\u6398\u91d1\u5173\u6ce8\u4eba\u6570\uff086k+\u4eba\uff09\u7b2c\u4e00\u7684\u4e13\u680f\uff0c\u5199\u6709\u51e0\u5341\u7bc7\u6e90\u7801\u6587\u7ae0\u3002<\/p>\n<p>\u521a\u521a\u7ed3\u675f\u4e0d\u4e45\u7684<a href=\"https:\/\/link.segmentfault.com\/?enc=pEO20py1t20GzFXGsGnTYg%3D%3D.A09xXMMiIfc4ob29IL6vqkssD7WH4IYZk5GmCnPiCiA%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">vueconf 2024 \u6df1\u5733<\/a>\uff0c\u6709\u4e00\u4e2a\u4e3b\u9898\u300aVue-Mini \u4e0d\u59a5\u534f\u7684\u5c0f\u7a0b\u5e8f\u6846\u67b6\u300b\uff0c<a href=\"https:\/\/link.segmentfault.com\/?enc=naao1yuIwywBeKVUGGtduw%3D%3D.utBQ0OkK4OFco6RjwdovpWQX2dA5aqbcqGgOR8l1ClCHHh1VG1ORe5%2BepdFIiX1y\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u4ed3\u5e93<\/a>\u3001<a href=\"https:\/\/link.segmentfault.com\/?enc=aYFcQLmhwPsQ3WXfipysmw%3D%3D.INfnMfaaSFrORmqiGT4NyfiD9jSfVQI2LvXTBi1A60gpmelfqr6Mj5sm8Jdfe%2BZwDqrejblxFQrW0NlsbYQsKqc955T7aNTAmcj9%2BleSx6k%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">PPT<\/a>\u3001<a href=\"https:\/\/www.bilibili.com\/video\/BV1J4421D7ja\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u89c6\u9891<\/a><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012231\" alt=\"vueconf.cn \u622a\u56fe\" title=\"vueconf.cn \u622a\u56fe\"><\/p>\n<p>PPT \u4e2d\u6709\u8fd9\u6837\u4e24\u9875\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012232\" alt=\"vuemini-vs-taro.png\" title=\"vuemini-vs-taro.png\" loading=\"lazy\"><\/p>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=tiXYrhegSSjR0GhCENlLPw%3D%3D.Px5VroM8LxJel7IzovIoZywFy8lx5vCeuC8GEpb2tHDnuvI%2B2l7DU7QOJ%2FBqtYZTy37dhZLWXYs6JrA%2FMl1pjQ%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u548c taro \u6027\u80fd\u5bf9\u6bd4\u6570\u636e\u7684\u4ed3\u5e93\u94fe\u63a5<\/a>\uff0c\u76ee\u524d\u4f5c\u8005\u6682\u672a\u7ed9\u51fa\u4e0e <code>uniapp<\/code> \u7684\u6027\u80fd\u5bf9\u6bd4\u3002<a href=\"https:\/\/link.segmentfault.com\/?enc=gslBdgHEu53pjCaU2jS0Bg%3D%3D.Cwl1lAgZEi%2FADk%2FkCOKSU8OTNVpMstFfPWmTa%2Fp7Vi6YiKid8Lh8wqFKayfWn1P7SfqHljPkWu9wzGccu8jhWA%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u6709\u5c0f\u4f19\u4f34\u5728 issue \u4e2d\u95ee\u5230\uff0c\u4f5c\u8005\u56de\u590d\u540e\u7eed\u4f1a\u8865\u4e0a<\/a><\/p>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=gLeileP9WUVt1rM5jFrGjg%3D%3D.pAvONf18Mvm58m2MUiwpjFGRAl8fQVCrj%2Baa9yKCnYdohNPeZU3iWCb0h2WX5dTX\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">vue-mini \u5b98\u7f51<\/a> \u4e0e\u5176\u4ed6\u7684\u6bd4\u8f83\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012233\" alt=\"vue-mini \u5b98\u7f51\u4e0e\u5176\u4ed6\u7684\u6bd4\u8f83\" title=\"vue-mini \u5b98\u7f51\u4e0e\u5176\u4ed6\u7684\u6bd4\u8f83\" loading=\"lazy\"><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012234\" alt=\"vue-mini \u5b98\u7f51\u4e0e\u5176\u4ed6\u7684\u6bd4\u8f832\" title=\"vue-mini \u5b98\u7f51\u4e0e\u5176\u4ed6\u7684\u6bd4\u8f832\" loading=\"lazy\"><\/p>\n<p>\u66f4\u591a\u517c\u5bb9\u6027\u548c\u4f7f\u7528\u65b9\u6cd5\u7b49\u67e5\u9605<a href=\"https:\/\/link.segmentfault.com\/?enc=w1ZNaduWw%2FzDLD4PJeWSbQ%3D%3D.CQGdLzdj9JYKG41Rp%2FL8aPnlk3C9iv7S7JJLA93QUkU%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">vue-mini \u6587\u6863<\/a>\u3002<\/p>\n<p>\u672c\u6587\u4e3b\u8981\u6765\u7b80\u5355\u4f53\u9a8c\u4e0b <code>vue-mini<\/code>\uff0c\u5e76\u4e14\u5b66\u4e60\u4e0b\u57fa\u672c\u7684\u6253\u5305\u6784\u5efa\u5927\u6982\u662f\u5982\u4f55\u5b9e\u73b0\u7684\u3002<\/p>\n<p>\u5b66\u5b8c\u672c\u6587\uff0c\u4f60\u5c06\u5b66\u5230\uff1a<\/p>\n<pre><code class=\"bash\">1. vue-mini \u521d\u6b65\u4f53\u9a8c\n2. \u521d\u59cb\u5316\u9879\u76ee\u4e2d\u7684 build.js \u662f\u5982\u4f55\u6253\u5305\u5c0f\u7a0b\u5e8f\u4ee3\u7801\u7684\n3. \u5982\u4f55\u5904\u7406 ts\u3001css\u3001html \u6587\u4ef6\n4. \u7b49\u7b49<\/code><\/pre>\n<h2>2. \u521d\u59cb\u5316\u9879\u76ee<\/h2>\n<p>\u6839\u636e <a href=\"https:\/\/link.segmentfault.com\/?enc=A9g28Ph%2FoRgoPhs3faqucw%3D%3D.xxeWYjorcbuR%2BY3siGgsRZ3feglUAzf27wLpq6dv8EhAoj9QwEoRyOwxbFDfucG5\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u5b98\u7f51\u6587\u6863\u5feb\u901f\u5f00\u59cb<\/a> \u751f\u6210\u5c0f\u7a0b\u5e8f\u9879\u76ee\uff0c\u6211\u91c7\u7528\u7684\u662f <code>pnpm create vue-mini@latest<\/code>\uff0c\u6211\u90fd\u9009\u62e9\u7684&#8221;\u662f&#8221;\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012235\" alt=\"screenshot-cli.png\" title=\"screenshot-cli.png\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u8c03\u7528\u7684\u662f <a href=\"https:\/\/link.segmentfault.com\/?enc=CBuHAGQcRHv%2BIuk7e2z9pA%3D%3D.Gcn1%2FjX5xBTJs6aS3c83Tm6tqdkH8qNRf8SiXQTqH%2B0HK4EHtCXH9uMJox5tjrzz\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">create-vue-mini<\/a> \u8fd9\u4e2a\u9879\u76ee\uff0c\u5199\u6587\u7ae0\u65f6\u7684\u7248\u672c\u662f <code>1.0.4<\/code>\u3002\u5b83\u7531 <a href=\"https:\/\/link.segmentfault.com\/?enc=GMXYsnr6cgT9YJG%2FbHRtwA%3D%3D.PtFSuco00MObHFoGhPpyxsdL6WhIsfwhTYWusazshAoFJWkwb6cy1rnK0fFXPJb0\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">create-vue<\/a> \u4fee\u6539\u800c\u6765\u3002\u6211\u572821\u5e74\u5199\u8fc7\u5b83\u7684\u6e90\u7801\u6587\u7ae0<a href=\"https:\/\/link.segmentfault.com\/?enc=6EqCFFFzxSZ0xMMz6vpI5A%3D%3D.yCLCM5uZDAAuzM%2B4q15h%2B04N7Tmg4EF6v6Qh3D8SUstmafmUGC6PFj9g0xkN4SgX\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">Vue \u56e2\u961f\u516c\u5f00\u5feb\u5982\u95ea\u7535\u7684\u5168\u65b0\u811a\u624b\u67b6\u5de5\u5177 create-vue\uff0c\u672a\u6765\u5c06\u66ff\u4ee3 Vue-CLI\uff0c\u624d300\u4f59\u884c\u4ee3\u7801\uff0c\u5b66\u5b83\uff01<\/a>\uff0c(3.9w+\u9605\u8bfb\u91cf\u3001483\u8d5e)\u53ef\u4f9b\u5b66\u4e60\u3002<\/p>\n<p>\u4e5f\u53ef\u4ee5\u76f4\u63a5\u514b\u9686\u6211\u7684\u9879\u76ee\u3002<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/ruochuan12\/vue-mini-analysis.git\ncd vue-mini-analysis\npnpm install<\/code><\/pre>\n<p>\u6267\u884c <code>pnpm install<\/code> \u4e4b\u540e\uff0c\u518d\u6267\u884c <code>pnpm run dev<\/code> \u6216\u8005 <code>pnpm run build<\/code> \u547d\u4ee4\u3002<\/p>\n<h2>3. \u4f53\u9a8c vue-mini<\/h2>\n<p>\u76f4\u63a5\u9009\u62e9\u9879\u76ee\u6839\u76ee\u5f55\u800c\u975e <code>dist<\/code> \u76ee\u5f55\uff0c\u5c06\u6b64\u9879\u76ee\u5bfc\u5165\u5fae\u4fe1\u5f00\u53d1\u8005\u5de5\u5177\u3002<\/p>\n<p>\u6253\u5f00\u9879\u76ee\u5982\u56fe\uff1a<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012236\" alt=\"vue-mini-project.png\" title=\"vue-mini-project.png\" loading=\"lazy\"><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012237\" alt=\"vue-mini-project-mine.png\" title=\"vue-mini-project-mine.png\" loading=\"lazy\"><\/p>\n<h3>3.1 \u5bf9\u6bd4\u6253\u5305\u6784\u5efa\u7684\u4ee3\u7801<\/h3>\n<p>\u6211\u4eec\u5177\u4f53\u6765\u5bf9\u6bd4\u6267\u884c <code>pnpm run dev<\/code> \u547d\u4ee4\u4e4b\u540e\u751f\u6210\u7684\u4ee3\u7801\u3002<\/p>\n<p>\u5165\u53e3 app.ts \u6587\u4ef6<br \/><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012238\" alt=\"\u5165\u53e3 app.ts \u6587\u4ef6\" title=\"\u5165\u53e3 app.ts \u6587\u4ef6\" loading=\"lazy\"><\/p>\n<p>\u9996\u9875 html \u6587\u4ef6<br \/><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012239\" alt=\"\u9996\u9875 html \u6587\u4ef6\" title=\"\u9996\u9875 html \u6587\u4ef6\" loading=\"lazy\"><\/p>\n<p>\u9996\u9875 css \u6587\u4ef6<br \/><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012240\" alt=\"\u9996\u9875 css \u6587\u4ef6\" title=\"\u9996\u9875 css \u6587\u4ef6\" loading=\"lazy\"><\/p>\n<p>\u9996\u9875 ts \u6587\u4ef6<br \/><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012241\" alt=\"\u9996\u9875 ts \u6587\u4ef6\" title=\"\u9996\u9875 ts \u6587\u4ef6\" loading=\"lazy\"><\/p>\n<p>\u9996\u9875 json \u6587\u4ef6<br \/><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012242\" alt=\"\u9996\u9875 json \u6587\u4ef6\" title=\"\u9996\u9875 json \u6587\u4ef6\" loading=\"lazy\"><\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u4e3b\u8981\u5c31\u662f\u5904\u7406\u5165\u53e3 <code>app.ts<\/code> \u6587\u4ef6\uff08\u5355\u72ec\u8ffd\u52a0\u4e86 <code>promise-polyfill<\/code>\uff09\u3001<code>html<\/code>\u3001<code>css<\/code>\u3001<code>ts<\/code>\u6587\u4ef6\u7f16\u8bd1\u6210\u4e86\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u652f\u6301\u7684 <code>app.js<\/code>\u3001<code>wxml<\/code>\u3001<code>wxss<\/code>\u3001<code>js<\/code>\u3002<code>json<\/code> \u6587\u4ef6\u662f\u76f4\u63a5\u590d\u5236\u7684\uff0c\u6ca1\u505a\u5904\u7406\u3002<\/p>\n<p>\u6362\u53e5\u8bdd\u8bf4\uff1a<br \/>\u6a21\u677f\u5199\u6cd5\u4f7f\u7528\u7684\u662f\u539f\u751f\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684<code>wxml<\/code>\uff0c\u53ea\u662f\u6539\u540d\u4e86 <code>html<\/code> \u800c\u5df2\uff0c<code>css<\/code> \u90e8\u5206\u4e5f\u662f\u539f\u751f\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684 <code>wxss<\/code> \u53ea\u662f\u5355\u4f4d <code>rpx<\/code> \u6539\u6210\u4e86 <code>px<\/code> \u800c\u5df2\uff0c\u672a\u505a\u7c7b\u4f3c\u5355\u6587\u4ef6\u7ec4\u4ef6\u7684\u7f16\u8bd1\u3002\u53ea\u662f\u5728\u903b\u8f91\u4fa7\uff0c<code>ts<\/code> \u6587\u4ef6\u4f7f\u7528\u4e86 <code>vue-mini\/core<\/code>\uff0c\u8f7b\u8fd0\u884c\u65f6\uff0c\u4f1a\u628a <code>ES Module<\/code> \u7f16\u8bd1\u6210 <code>commonjs<\/code>\u3002<\/p>\n<h3>3.2 dev \u548c build \u547d\u4ee4<\/h3>\n<p><code>pnpm run dev<\/code> \u548c <code>pnpm run build<\/code> \u5206\u522b\u5bf9\u5e94\u7684\u662f <code>package.json<\/code> \u4e2d\u7684\u4e24\u4e2a\u547d\u4ee4\u3002<\/p>\n<pre><code class=\"json\">\/\/ package.json\n{\n &quot;scripts&quot;: {\n  &quot;dev&quot;: &quot;cross-env NODE_ENV=development node build.js&quot;,\n  &quot;build&quot;: &quot;cross-env NODE_ENV=production node build.js&quot;\n }\n}<\/code><\/pre>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=VnmKgQPl2E43aghldP0w%2Fg%3D%3D.D1QS2aUzOk4LagexqfzyXobpDjbOGpsHIAw1fo1iMJuUiV08do8ceeUvMeLZJmEH\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">cross-env<\/a> \u662f\u7528\u6765\u8de8\u5e73\u53f0\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u7684\uff0c<code>NODE_ENV=development<\/code> \u4ee3\u8868\u5f00\u53d1\u73af\u5883\uff0c<code>NODE_ENV=production<\/code> \u4ee3\u8868\u751f\u4ea7\u73af\u5883\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u6253\u5f00 <code>build.js<\/code> \u6587\u4ef6\uff0c\u67e5\u770b\u4e0b\u5b83\u7684\u4ee3\u7801\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012243\" alt=\"build.png\" title=\"build.png\" loading=\"lazy\"><\/p>\n<p>\u8c03\u8bd5\u53ef\u53c2\u8003\u6211\u7684\u6587\u7ae0<a href=\"https:\/\/link.segmentfault.com\/?enc=ZMnJ6zn3j4iwyh3DEVHtFQ%3D%3D.DjoSyp80lTQoI7eQjODREQPZ1jvJfgverteSWEXZMEioqmJDkr1LoCzdQThHr3y8\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u65b0\u624b\u5411\uff1a\u524d\u7aef\u7a0b\u5e8f\u5458\u5fc5\u5b66\u57fa\u672c\u6280\u80fd\u2014\u2014\u8c03\u8bd5 JS \u4ee3\u7801<\/a>\uff0c\u6216\u8005<a href=\"https:\/\/link.segmentfault.com\/?enc=LUAb%2FRMICh9bpVgHOubURQ%3D%3D.Nh%2BWZit%2FYo92utO8UJb5jzMxVQz5NAHgfieoEyK6QpMGO8QrvzPcXYmKMpd2vD4B\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u636e\u8bf4 90%\u7684\u4eba\u4e0d\u77e5\u9053\u53ef\u4ee5\u7528\u6d4b\u8bd5\u7528\u4f8b(Vitest)\u8c03\u8bd5\u5f00\u6e90\u9879\u76ee(Vue3) \u6e90\u7801<\/a>\u3002\u672c\u6587\u5c31\u4e0d\u505a\u8fc7\u591a\u8d58\u8ff0\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012244\" alt=\"debugger.png\" title=\"debugger.png\" loading=\"lazy\"><\/p>\n<p><code>build.js<\/code> \u76ee\u524d\u662f\u6bd4\u8f83\u539f\u59cb\u7684\u65b9\u5f0f\uff0c\u6ca1\u6709\u5404\u79cd\u5c01\u88c5\uff0c\u76f8\u5bf9\u5bb9\u6613\u5b66\u4e60\u3002\u6709\u5c0f\u4f19\u4f34\u63d0\u5efa\u8bae<a href=\"https:\/\/link.segmentfault.com\/?enc=IdTYcA1i8AK97yG1lJL6pQ%3D%3D.sgEfRAZ5eSbE%2BJXHrvopmh2F4gAhUX8PrAgRt4C2jNEoitCNSSgKu5Lt9pgPbidQ\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">[Feature] \u5e0c\u671b\u53ef\u4ee5\u589e\u5f3a\u5de5\u7a0b\u5316\u7b49\u57fa\u5efa\u4f53\u9a8c #65<\/a>\u3002<\/p>\n<p>\u8ba9\u6211\u60f3\u8d77\u5f88\u4e45\u5f88\u4e45\u4ee5\u524d\uff08\u5927\u7ea6\u662f6\u5e74\u524d\uff09\uff0c<code>vue-cli@2.9.3<\/code> \u7248\u672c\u65f6\u5c31\u662f\u7528\u751f\u6210 <code>vue<\/code> \u9879\u76ee\u5c31\u662f\u76f4\u63a5\u751f\u6210\u5728\u5f00\u53d1\u8005\u7684\u9879\u76ee\u4e2d\u3002\u6bd4\u8f83\u96be\u4ee5\u548c\u5b98\u65b9\u4fdd\u6301\u540c\u6b65\u5347\u7ea7\u3002\u540e\u6765 <code>vue-cli@3.0<\/code> \u4e4b\u540e\u7248\u672c\u5c31\u80fd\u76f8\u5bf9\u5bb9\u6613\u5347\u7ea7\u4e86\u3002<\/p>\n<blockquote><p>\u5f53\u65f6\u5199\u8fc7\u4e00\u7bc7\u6587\u7ae0<a href=\"https:\/\/link.segmentfault.com\/?enc=c9pN3gQYgoMBKBU5UYZbpw%3D%3D.LwtABt1uDMSk96L%2FeWEEpwoyTy8xLn164UqvdVvW8a1dfj%2B37DcUjY5itsrDtMc6\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u5206\u6790vue-cli@2.9.3 \u642d\u5efa\u7684webpack\u9879\u76ee\u5de5\u7a0b<\/a>\uff0cwebpack \u914d\u7f6e\u76f8\u5173\u53ef\u80fd\u8fc7\u65f6\u4e86\uff0c\u4f46\u5176\u4ed6\u77e5\u8bc6\u6ca1\u6709\u8fc7\u65f6\uff0c\u611f\u5174\u8da3\u7684\u5c0f\u4f19\u4f34\u53ef\u4ee5\u5b66\u4e60\u3002<\/p><\/blockquote>\n<h2>3. build.js \u6253\u5305\u6784\u5efa\u6587\u4ef6<\/h2>\n<h3>3.1 \u5f15\u5165\u5404\u79cd\u4f9d\u8d56<\/h3>\n<pre><code class=\"ts\">\/\/ \u5f15\u5165 node path \u6a21\u5757\u548c process \u6a21\u5757\nimport path from 'node:path';\nimport process from 'node:process';<\/code><\/pre>\n<blockquote><p>\u5f15\u5165 node path \u6a21\u5757\u548c process \u6a21\u5757<\/p><\/blockquote>\n<pre><code class=\"js\">import fs from 'fs-extra';\nimport chokidar from 'chokidar';<\/code><\/pre>\n<blockquote><p>\u5f15\u5165 <a href=\"https:\/\/link.segmentfault.com\/?enc=6c3%2Be8rCni26peKv2cEVLQ%3D%3D.dU%2FS%2Bv6BGoqrk0C0hDDKdVzvcSjg7al%2BOtXYHoP%2FVhsWeV1Lzeoff6f1Rob9g0Sx\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">fs-extra<\/a> \u6a21\u5757\uff0c\u7528\u6765\u64cd\u4f5c\u6587\u4ef6\u548c\u76ee\u5f55\/<br \/>\u5f15\u5165 <a href=\"https:\/\/link.segmentfault.com\/?enc=yFZndkG5jp9oyYHQDlRUnw%3D%3D.Gm7aJbH6Eb4mMFqeFKpUNSju5EhtDgsTCIaGnaP%2BeduDIvQ2B0TKYG1YpGacQZJD\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">chokidar<\/a> \u6a21\u5757\uff0c\u7528\u6765\u76d1\u542c\u6587\u4ef6\u53d8\u5316<\/p><\/blockquote>\n<pre><code class=\"js\">import babel from '@babel\/core';\nimport traverse from '@babel\/traverse';\nimport t from '@babel\/types';\nimport { minify } from 'terser';<\/code><\/pre>\n<blockquote><p>\u5f15\u5165 <a href=\"https:\/\/link.segmentfault.com\/?enc=CiTLEO3zjTIxSS8LoM%2BMEw%3D%3D.tdgz4qozx3g4JpaZcIjllROWoB5%2BpxaZYJnunU8fSobK%2B0FZwqg7Q2lPm%2Bt3XBYa\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@babel\/core<\/a> \u6a21\u5757\uff0c\u7528\u6765\u7f16\u8bd1 js \u4ee3\u7801\/<br \/>\u5f15\u5165 <a href=\"https:\/\/link.segmentfault.com\/?enc=WITrEwIVCCbFOirZ4H0NaQ%3D%3D.Hsj6sEjZQlBILv7nL4UZMNycVG2smQUCIxri2i2%2Boe1brj76wsTSJbgNQoFkS4cs\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@babel\/traverse<\/a> \u6a21\u5757\uff0c\u7528\u6765\u904d\u5386 js \u4ee3\u7801\/<br \/>\u5f15\u5165 <a href=\"https:\/\/link.segmentfault.com\/?enc=7%2B9nsOiF4KQbZWt%2B074F9Q%3D%3D.sfvTr%2FUcs3jfU8CiNDM15PvrS%2FM1wschYU8lYpm7ZudPdEMdkyirHzEdQ8742sbx\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@babel\/types<\/a> \u6a21\u5757\uff0c\u7528\u6765\u7f16\u8bd1 js \u4ee3\u7801\/<br \/>\u5f15\u5165 <a href=\"https:\/\/link.segmentfault.com\/?enc=MTrTeN3J6laX5kEum%2FIKrg%3D%3D.vvOm13fVRg2v%2FkOlPpN%2FSuZnpXTLpC2Qnt2MtN%2Bdj87xzb%2FxQ3smxCSauDUbb7hF\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">terser<\/a> \u6a21\u5757\uff0c\u7528\u6765\u538b\u7f29 js \u4ee3\u7801<\/p><\/blockquote>\n<pre><code class=\"js\">import postcss from 'postcss';\nimport postcssrc from 'postcss-load-config';<\/code><\/pre>\n<blockquote><p>\u5f15\u5165 <a href=\"https:\/\/link.segmentfault.com\/?enc=%2B5f3kyNR0%2FnuuEua6z0dFg%3D%3D.HtRuqexry5DD0efMB%2BGXm1gtujC0v90jVmtKKjg1CYUMsRkwi3oo6c1k4nAzD2O5\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">postcss<\/a> \u6a21\u5757\uff0c\u7528\u6765\u7f16\u8bd1 css \u4ee3\u7801\/<br \/>\u5f15\u5165 <a href=\"https:\/\/link.segmentfault.com\/?enc=xSKHMDoylV9EhG9CrxOJng%3D%3D.DeWar24%2BX39nx8JDpcCHXw6tle7MOAltZUGlqmr03NjdMs1WIxvGFMxI%2BInBYmF973iRtxO%2BEyvmvnlVMIrlOg%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">postcss-load-config<\/a> \u6a21\u5757\uff0c\u7528\u6765\u52a0\u8f7d postcss \u914d\u7f6e\u6587\u4ef6<\/p><\/blockquote>\n<pre><code class=\"js\">import { rollup } from 'rollup';\nimport replace from '@rollup\/plugin-replace';\nimport terser from '@rollup\/plugin-terser';\nimport resolve from '@rollup\/plugin-node-resolve';\nimport commonjs from '@rollup\/plugin-commonjs';<\/code><\/pre>\n<blockquote><p>\u5f15\u5165 <a href=\"https:\/\/link.segmentfault.com\/?enc=1XdiL1SYtizNtajxoU8elQ%3D%3D.clOpIsSW8XePrUFH63FXtJffor2jWb00x%2F0Nu3Tr5soC8lCB54xepKsksLjM%2ByYZ\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">rollup<\/a> \u6a21\u5757\uff0c\u7528\u6765\u6253\u5305 js \u4ee3\u7801\/<br \/>\u5f15\u5165 <a href=\"https:\/\/link.segmentfault.com\/?enc=bwYRKDpCaZGadhhzuF2MuA%3D%3D.zwsP0FeZmVIPnr3l%2F%2B7KmzotVlGsDnZTknt2Ap5R%2BBuVsQVtkSLXjwU0DDBWqVBwdIyuYIFVsfOgbsBWEWjoqA%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@rollup\/plugin-replace<\/a> \u6a21\u5757\uff0c\u7528\u6765\u66ff\u6362\u4ee3\u7801\/<br \/>\u5f15\u5165 <a href=\"https:\/\/link.segmentfault.com\/?enc=ybgCeuzlfcnKpVhhQpBiAA%3D%3D.3APAPaP1LY%2BRLvgdq%2BDhbmAkIgaXPG%2BVvoYRoDPpymnMGfOPorim1RdU8ESyVZTOKgXjRjtfQvlyrXrg7g8eeg%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@rollup\/plugin-terser<\/a> \u6a21\u5757\uff0c\u7528\u6765\u538b\u7f29 js \u4ee3\u7801\/<br \/>\u5f15\u5165 <a href=\"https:\/\/link.segmentfault.com\/?enc=6RmVfeeTQcUH%2FvrtTPRqyA%3D%3D.tAQn9nemB4sORcaeZxKGr0ApGHu2hXfSi3V5HuOnVqzO0ag%2FjHGMStwngYOyD0oUle9SDWnKeO05OPRs493p40TRfM0fG9VUse%2BjEgWX9%2BQ%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@rollup\/plugin-node-resolve<\/a> \u6a21\u5757\uff0c\u7528\u6765\u89e3\u6790 node\/_modules \u4e2d\u7684\u4f9d\u8d56\/<br \/>\u5f15\u5165 <a href=\"https:\/\/link.segmentfault.com\/?enc=CsbbF0dsNbHwAmQPRdwMkQ%3D%3D.acp5pWqTXh55T0iMWCkXplBfyialw0KCtTXS4WhcdEXRcuRbjR6V5p5k0OsEfdUUOHFBD7uSx%2F79f0nmG8tNpw%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@rollup\/commonjs<\/a> \u6a21\u5757\uff0c\u7528\u6765\u89e3\u6790 commonjs \u4f9d\u8d56<\/p><\/blockquote>\n<pre><code class=\"js\">import { green, bold } from 'kolorist';<\/code><\/pre>\n<blockquote><p>\u5f15\u5165 <a href=\"https:\/\/link.segmentfault.com\/?enc=1vB2aZEi4e3QgUYIGj21cA%3D%3D.Ne9ELYgfEgy1QAlKkv6oy6jUiNnIxAm%2FdsEDGroTPdSWF6b1Ns2tkfGmVJfoeXNk\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">kolorist<\/a> \u6a21\u5757\uff0c\u7528\u6765\u8f93\u51fa\u5f69\u8272\u6587\u5b57<\/p><\/blockquote>\n<h3>3.2 \u5b9a\u4e49\u53d8\u91cf<\/h3>\n<pre><code class=\"js\">\/\/ \u7b49\u5f85\u5217\u8868\uff0c promise \u6570\u7ec4\nlet waitList = [];\n\/\/ \u5f00\u59cb\u65f6\u95f4\uff0c\u8ba1\u7b97\u6700\u7ec8\u6253\u5305\u65f6\u95f4\nconst startTime = Date.now();\n\/\/ \u533a\u5206\u5f00\u53d1\u73af\u5883\u548c\u751f\u4ea7\u73af\u5883\nconst NODE_ENV = process.env.NODE_ENV || 'production';\n\/\/ \u751f\u4ea7\u73af\u5883\nconst __PROD__ = NODE_ENV === 'production';\n\/\/ \u538b\u7f29\u4ee3\u7801\u7684\u914d\u7f6e\nconst terserOptions = {\n  ecma: 2016,\n  toplevel: true,\n  safari10: true,\n  format: { comments: false },\n};\n\n\/\/ \u8bb0\u5f55\u6253\u5305\u7684\u6a21\u5757\uff0c\u65b9\u4fbf\u907f\u514d\u91cd\u590d\u6253\u5305\nconst bundledModules = new Set();<\/code><\/pre>\n<h3>3.3 \u8c03\u7528 prod \u6216\u8005 dev<\/h3>\n<pre><code class=\"js\">if (__PROD__) {\n  await prod();\n} else {\n  await dev();\n}<\/code><\/pre>\n<p>\u6211\u4eec\u5148\u6765\u770b <code>prod<\/code> \u51fd\u6570\uff0c\u518d\u770b <code>dev<\/code> \u51fd\u6570\u3002<\/p>\n<h3>3.4 prod \u51fd\u6570<\/h3>\n<pre><code class=\"js\">async function prod() {\n  await fs.remove('dist');\n  const watcher = chokidar.watch(['src'], {\n    ignored: ['**\/.{gitkeep,DS_Store}'],\n  });\n  watcher.on('add', (filePath) =&gt; {\n    const promise = cb(filePath);\n    waitList.push(promise);\n  });\n  watcher.on('ready', async () =&gt; {\n    const promise = watcher.close();\n    waitList.push(promise);\n    await Promise.all(waitList);\n    console.log(bold(green(`\u6784\u5efa\u5b8c\u6210\uff0c\u8017\u65f6\uff1a${Date.now() - startTime}ms`)));\n  });\n}<\/code><\/pre>\n<p>\u8fd9\u4e2a\u51fd\u6570\u4e3b\u8981\u505a\u4e86\u4ee5\u4e0b\u51e0\u4ef6\u4e8b\uff1a<\/p>\n<ol>\n<li>\u79fb\u9664 dist \u76ee\u5f55<\/li>\n<li>\u76d1\u542c src \u76ee\u5f55<\/li>\n<li>\u5bf9\u4e8e\u76d1\u542c\u7684\u6587\u4ef6\uff0c\u8c03\u7528 cb \u51fd\u6570\uff0c\u628a\u8fd4\u56de\u7684 promise \uff0c\u5b58\u5165\u6570\u7ec4 waitList\u3002<\/li>\n<li>\u6700\u540e\u8c03\u7528 Promise.all(waitList) \u6267\u884c\u6240\u6709\u7684 <code>promise<\/code>\u3002<\/li>\n<li>\u6700\u540e\u6253\u5370\u6784\u5efa\u65f6\u957f\u3002<\/li>\n<\/ol>\n<h3>3.5 dev \u51fd\u6570<\/h3>\n<pre><code class=\"js\">async function dev() {\n  await fs.remove('dist');\n  chokidar\n    .watch(['src'], {\n      ignored: ['**\/.{gitkeep,DS_Store}'],\n    })\n    .on('add', (filePath) =&gt; {\n      const promise = cb(filePath);\n      waitList?.push(promise);\n    })\n    .on('change', (filePath) =&gt; {\n      cb(filePath);\n    })\n    .on('ready', async () =&gt; {\n      await Promise.all(waitList);\n      console.log(bold(green(`\u542f\u52a8\u5b8c\u6210\uff0c\u8017\u65f6\uff1a${Date.now() - startTime}ms`)));\n      console.log(bold(green('\u76d1\u542c\u6587\u4ef6\u53d8\u5316\u4e2d...')));\n      \/\/ Release memory.\n      waitList = null;\n    });\n}<\/code><\/pre>\n<p>\u8fd9\u4e2a\u51fd\u6570\u548c prod \u51fd\u6570\u7c7b\u4f3c\uff0c\u4e3b\u8981\u505a\u4e86\u4ee5\u4e0b\u51e0\u4ef6\u4e8b\uff1a<\/p>\n<ol>\n<li>\u79fb\u9664 dist \u76ee\u5f55<\/li>\n<li>\u76d1\u542c src \u76ee\u5f55<\/li>\n<li>\u5bf9\u4e8e\u76d1\u542c\u7684\u6587\u4ef6\uff0c\u8c03\u7528 cb \u51fd\u6570\uff0c\u628a\u8fd4\u56de\u7684 promise \uff0c\u5b58\u5165\u6570\u7ec4 waitList\u3002<\/li>\n<li>\u6587\u4ef6\u6539\u53d8\u65f6\uff0c\u8c03\u7528 cb \u51fd\u6570\u3002<\/li>\n<li>\u8c03\u7528 Promise.all(waitList) \u6267\u884c\u6240\u6709\u7684 <code>promise<\/code>\u3002<\/li>\n<li>\u6700\u540e\u6253\u5370\u542f\u52a8\u65f6\u957f\uff0c\u6e05\u7a7a waitList\u3002<\/li>\n<\/ol>\n<p>\u6211\u4eec\u63a5\u7740\u6765\u770b\uff0c<code>cb<\/code> \u51fd\u6570\uff0c\u8fd9\u4e2a\u51fd\u6570\u7528\u6765\u5904\u7406\u6587\u4ef6\u53d8\u5316\u3002<\/p>\n<pre><code class=\"js\">const cb = async (filePath) =&gt; {\n  if (\/\/.ts$\/.test(filePath)) {\n    await processScript(filePath);\n    return;\n  }\n\n  if (\/\/.html$\/.test(filePath)) {\n    await processTemplate(filePath);\n    return;\n  }\n\n  if (\/\/.css$\/.test(filePath)) {\n    await processStyle(filePath);\n    return;\n  }\n\n  await fs.copy(filePath, filePath.replace('src', 'dist'));\n};<\/code><\/pre>\n<p><code>cb<\/code> \u51fd\u6570\u4e3b\u8981\u7528\u6765\u5904\u7406 <code>ts\u3001html\u3001css<\/code> \u6587\u4ef6\u548c\u590d\u5236\u6587\u4ef6\u5230 <code>dist<\/code> \u76ee\u5f55\u3002<\/p>\n<p>\u5206\u522b\u6765\u770b\u8fd9\u51e0\u4e2a\u51fd\u6570\u7684\u5b9e\u73b0\uff0c\u6211\u4eec\u5148\u770b <code>processScript<\/code> \u5904\u7406 <code>ts<\/code> \u6587\u4ef6<\/p>\n<h3>3.6 processScript \u5904\u7406 ts<\/h3>\n<pre><code class=\"js\">async function processScript(filePath) {\n  let ast, code;\n  try {\n    const result = await babel.transformFileAsync(path.resolve(filePath), {\n      ast: true,\n    });\n    ast = result.ast;\n    code = result.code;\n  } catch (error) {\n    console.error(`Failed to compile ${filePath}`);\n\n    if (__PROD__) throw error;\n\n    console.error(error);\n    return;\n  }<\/code><\/pre>\n<p>\u4f7f\u7528 <a href=\"https:\/\/link.segmentfault.com\/?enc=YnoML8guRMdAI%2Bag6Rla4g%3D%3D.JBCr0b8PFBenNKP3wL9GTu%2FcL1bXSrPjmvuWMN2ts%2BrTF9vUf3xMA%2BCKoYX%2FPoNur0jRSnBZN0nUnjGXyXXinw%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">babel.transformFileAsync<\/a> \u5f02\u6b65\u5730\u5c06\u6587\u4ef6\u5185\u5bb9\u8f6c\u6362\u4e3a\u62bd\u8c61\u8bed\u6cd5\u6811\uff08AST\uff09\u548c\u8f6c\u6362\u540e\u7684\u4ee3\u7801\u3002<\/p>\n<pre><code class=\"js\">  if (filePath.endsWith('app.ts')) {\n    \/**\n     * IOS \u5c0f\u7a0b\u5e8f Promise \u4f7f\u7528\u7684\u5185\u7f6e\u7684 Polyfill\uff0c\u4f46\u8fd9\u4e2a Polyfill \u6709 Bug \u4e14\u529f\u80fd\u4e0d\u5168\uff0c\n     * \u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b Promise \u56de\u8c03\u4e0d\u4f1a\u6267\u884c\uff0c\u5e76\u4e14\u4e0d\u652f\u6301 Promise.prototype.finally\u3002\n     * \u8fd9\u91cc\u5c06\u5168\u5c40\u7684 Promise \u53d8\u91cf\u91cd\u5199\u4e3a\u81ea\u5b9a\u4e49\u7684 Polyfill\uff0c\u5982\u679c\u4f60\u4e0d\u9700\u8981\u517c\u5bb9 iOS10 \u4e5f\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u5f0f\uff1a\n     * Promise = Object.getPrototypeOf((async () =&gt; {})()).constructor;\n     * \u5199\u5728\u6b64\u5904\u662f\u4e3a\u4e86\u4fdd\u8bc1 Promise \u91cd\u5199\u6700\u5148\u88ab\u6267\u884c\u3002\n     *\/\n    code = code.replace(\n      '&quot;use strict&quot;;',\n      '&quot;use strict&quot;;\/n\/nvar PromisePolyfill = require(&quot;promise-polyfill&quot;);\/nPromise = PromisePolyfill.default;',\n    );\n    const promise = bundleModule('promise-polyfill');\n    waitList?.push(promise);\n  }<\/code><\/pre>\n<p>\u66ff\u6362\u4ee3\u7801 &#8216;&#8221;use strict&#8221;;&#8217;\uff0c\u8ffd\u52a0 <code>Promise<\/code> \u7684 Polyfill\uff0c\u8fd9\u91cc\u4f7f\u7528\u7684\u662f <a href=\"https:\/\/link.segmentfault.com\/?enc=8qU8l1XdrFfEH5UriFW%2BVw%3D%3D.Ci8z7595ntG%2FtPB2nr00JmUSpXrWIuK7xSc1%2Fg0FF%2Fti78qwN1SMm6FesUq87HUt\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">promise-polyfill<\/a>\u3002<\/p>\n<pre><code class=\"js\">  traverse.default(ast, {\n    CallExpression({ node }) {\n      if (\n        node.callee.name !== 'require' ||\n        !t.isStringLiteral(node.arguments[0]) ||\n        node.arguments[0].value.startsWith('.')\n      ) {\n        return;\n      }\n\n      const promise = bundleModule(node.arguments[0].value);\n      waitList?.push(promise);\n    },\n  });<\/code><\/pre>\n<p>\u904d\u5386 <code>AST<\/code>\uff0c\u627e\u5230 <code>CallExpression<\/code> \u8282\u70b9\uff0c\u5224\u65ad\u662f\u5426\u4e3a <code>require<\/code> \u51fd\u6570\uff0c\u5e76\u4e14\u53c2\u6570\u662f\u5b57\u7b26\u4e32\uff0c\u4e14\u4e0d\u662f\u76f8\u5bf9\u8def\u5f84\u3002<\/p>\n<pre><code class=\"js\">  \/\/ \u751f\u4ea7\u73af\u5883\u538b\u7f29\u4ee3\u7801\n  if (__PROD__) {\n    code = (await minify(code, terserOptions)).code;\n  }\n\n  const destination = filePath.replace('src', 'dist').replace(\/\/.ts$\/, '.js');\n  \/\/ Make sure the directory already exists when write file\n  await fs.copy(filePath, destination);\n  await fs.writeFile(destination, code);\n}<\/code><\/pre>\n<p>\u7ecf\u8fc7\u4ee5\u4e0a\u5904\u7406\u540e\uff0c<code>src\/pages\/home\/index.ts<\/code> \u53d8\u6210\u4e86 <code>dist\/pages\/home\/index.js<\/code>\uff0c\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre><code class=\"js\">\/\/ src\/pages\/home\/index.ts\nimport { defineComponent, ref } from '@vue-mini\/core';\n\ndefineComponent(() =&gt; {\n  const greeting = ref('\u6b22\u8fce\u4f7f\u7528 Vue Mini');\n\n  return {\n    greeting,\n  };\n});<\/code><\/pre>\n<pre><code class=\"js\">&quot;use strict&quot;;\n\nvar _core = require(&quot;@vue-mini\/core&quot;);\n(0, _core.defineComponent)(() =&gt; {\n  const greeting = (0, _core.ref)('\u6b22\u8fce\u4f7f\u7528 Vue Mini');\n  return {\n    greeting\n  };\n});<\/code><\/pre>\n<p>\u6211\u4eec\u6765\u7b80\u5355\u770b\u4e0b babel \u914d\u7f6e\u3002<\/p>\n<h4>3.6.1 babel.config.js babel \u914d\u7f6e\u6587\u4ef6<\/h4>\n<pre><code class=\"js\">\/\/ babel.config.js\nimport fs from 'node:fs';\n\nconst runtimeVersion = JSON.parse(\n  fs.readFileSync(\n    new URL(import.meta.resolve('@babel\/runtime\/package.json')),\n    'utf8',\n  ),\n).version;\n\nconst config = {\n  targets: {},\n  assumptions: {\n    \/\/ \u7701\u7565\u82e5\u5e72\u4ee3\u7801\n  },\n  presets: [\n    [\n      '@babel\/preset-env',\n      {\n        bugfixes: true,\n        modules: 'commonjs',\n      },\n    ],\n    '@babel\/preset-typescript',\n  ],\n  plugins: [\n    [\n      '@babel\/plugin-transform-runtime',\n      {\n        version: runtimeVersion,\n      },\n    ],\n    'transform-inline-environment-variables',\n    [\n      'module-resolver',\n      {\n        alias: {\n          '@': '.\/src',\n        },\n      },\n    ],\n    'autocomplete-index',\n  ],\n};\n\nexport default config;<\/code><\/pre>\n<p>\u6211\u4eec\u7ee7\u7eed\u6765\u770b <code>bundleModule<\/code> \u51fd\u6570\u7684\u5177\u4f53\u5b9e\u73b0\u3002<\/p>\n<h3>3.7 bundleModule \u6253\u5305\u6a21\u5757<\/h3>\n<pre><code class=\"js\">async function bundleModule(module) {\n  if (bundledModules.has(module)) return;\n  bundledModules.add(module);\n\n  const bundle = await rollup({\n    input: module,\n    plugins: [\n      commonjs(),\n      replace({\n        preventAssignment: true,\n        values: {\n          'process.env.NODE_ENV': JSON.stringify(NODE_ENV),\n        },\n      }),\n      resolve(),\n      __PROD__ &amp;&amp; terser(terserOptions),\n    ].filter(Boolean),\n  });\n  await bundle.write({\n    exports: 'named',\n    file: `dist\/miniprogram_npm\/${module}\/index.js`,\n    format: 'cjs',\n  });\n}<\/code><\/pre>\n<p>\u5982\u679c\u5df2\u7ecf\u6709\u6253\u5305\u597d\u7684\u6a21\u5757\uff0c\u76f4\u63a5\u8fd4\u56de\u3002<br \/>\u7528 <code>rollup<\/code> \u6253\u5305\u6a21\u5757\uff0c\u5904\u7406\u6210 <code>commonjs<\/code>\uff0c\u5e76\u5199\u5165 <code>dist\/miniprogram_npm<\/code> \u76ee\u5f55\u3002<\/p>\n<p>\u5982\u56fe\u6240\u793a\uff1a<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012245\" alt=\"npm.png\" title=\"npm.png\" loading=\"lazy\"><\/p>\n<p>\u6211\u4eec\u7ee7\u7eed\u6765\u770b <code>html<\/code> \u6587\u4ef6\u5904\u7406\uff1a<\/p>\n<h3>3.8 processTemplate \u5904\u7406\u6a21\u677f html<\/h3>\n<pre><code class=\"js\">async function processTemplate(filePath) {\n  const destination = filePath\n    .replace('src', 'dist')\n    .replace(\/\/.html$\/, '.wxml');\n  await fs.copy(filePath, destination);\n}<\/code><\/pre>\n<p>\u8fd9\u4e2a\u51fd\u6570\u76f8\u5bf9\u7b80\u5355\uff0c\u5c31\u662f\u590d\u5236 <code>src<\/code> <code>html<\/code> \u6587\u4ef6\u4fee\u6539\u540e\u7f00\u540d\u4e3a <code>.wxml<\/code> \u6587\u4ef6\u5230 <code>dist<\/code> \u76ee\u5f55\u3002<\/p>\n<h3>3.9 processStyle \u5904\u7406\u6837\u5f0f\u6587\u4ef6<\/h3>\n<pre><code class=\"js\">async function processStyle(filePath) {\n  \/\/ \u8bfb\u53d6\u6837\u5f0f\u6587\u4ef6\n  const source = await fs.readFile(filePath, 'utf8');\n  \/\/ \u8bfb\u53d6\u914d\u7f6e postcss.config.js\n  const { plugins, options } = await postcssrc({ from: undefined });\n\n  let css;\n  try {\n    const result = await postcss(plugins).process(source, options);\n    css = result.css;\n  } catch (error) {\n    console.error(`Failed to compile ${filePath}`);\n\n    \/\/ \u751f\u4ea7\u73af\u5883\u6253\u5305\u6784\u5efa\u65f6\uff0c\u629b\u51fa\u9519\u8bef\n    if (__PROD__) throw error;\n\n    console.error(error);\n    return;\n  }\n\n  const destination = filePath\n    .replace('src', 'dist')\n    .replace(\/\/.css$\/, '.wxss');\n  \/\/ Make sure the directory already exists when write file\n  await fs.copy(filePath, destination);\n  await fs.writeFile(destination, css);\n}<\/code><\/pre>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=90WLLQ1s7K22jlXQ6lu9uQ%3D%3D.jR7%2BzTWPEoEQAicIshbuY22yUZRm3QccBEkZI7F8Eo%2FMeEZpVti5hV7V%2BR6VLH%2FfZO%2Fa120BpTZeKqq2PjW%2FpQ%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">postcss-load-config<\/a> <code>Autoload Config for PostCSS<\/code> \u662f\u81ea\u52a8\u52a0\u8f7d <code>postcss.config.js<\/code> \u7b49\u914d\u7f6e\u6587\u4ef6\uff0c\u5e76\u89e3\u6790\u5176\u4e2d\u7684\u63d2\u4ef6\u3002<br \/>\u7136\u540e\u8c03\u7528 <code>postcss<\/code> \u89e3\u6790\u6837\u5f0f\u6587\u4ef6\uff0c\u5e76\u5199\u5165 <code>dist<\/code> \u76ee\u5f55\u3002<\/p>\n<h4>3.9.1 postcss.config.js postcss \u914d\u7f6e\u6587\u4ef6<\/h4>\n<pre><code class=\"js\">\/\/ postcss.config.js\nimport pxtorpx from 'postcss-pxtorpx-pro';\n\nconst config = {\n  plugins: [pxtorpx({ transform: (x) =&gt; x })],\n};\n\nexport default config;<\/code><\/pre>\n<p>\u5f15\u5165 <a href=\"https:\/\/link.segmentfault.com\/?enc=1jInIbWyNpGsT7PWJiLtOg%3D%3D.mzoSV2hmMlqfJS3Kwmnbj8K7H8lfg5WqvWFvOMVX9i5ssYYPV6xR3AJ601VU8jtBaz4lUfVzowucM2Q%2FD%2BBYNA%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">postcss-pxtorpx-pro<\/a> \u63d2\u4ef6\uff0c\u5c06 <code>px<\/code> \u8f6c\u6362\u4e3a <code>rpx<\/code>\u3002<\/p>\n<p>\u5904\u7406 <code>px<\/code> \u4e3a <code>rpx<\/code> \u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre><code class=\"css\">\/\/ input\nh1 {\n    margin: 0 0 20px;\n    font-size: 32px;\n    line-height: 1.2;\n    letter-spacing: 1px;\n}\n\n\/\/ output\nh1 {\n  margin: 0 0 40rpx;\n  font-size: 64rpx;\n  line-height: 1.2;\n  letter-spacing: 2rpx;\n}<\/code><\/pre>\n<h2>4. \u603b\u7ed3<\/h2>\n<p>\u6211\u4eec\u5b66\u4e60\u4e86\u521d\u59cb\u5316\u9879\u76ee\u4e2d\u7684 <code>build.js<\/code> \u662f\u5982\u4f55\u6253\u5305\u5c0f\u7a0b\u5e8f\u4ee3\u7801\u7684\u3002<\/p>\n<p>\u5b66\u4e60\u4e86\u4f7f\u7528 <code>cross-env<\/code> \u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u4f7f\u7528 <code>chokidar<\/code> \u76d1\u542c\u6587\u4ef6\u53d8\u52a8\u3002<code>html<\/code> \u6587\u4ef6\u5c31\u662f\u539f\u751f\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684wxml\uff0c\u76f4\u63a5\u590d\u5236\u7c98\u8d34\u4fee\u6539\u4e86\u540e\u7f00\u540d\u5230<code>dist<\/code>\u76ee\u5f55\u3002 \u4f7f\u7528 <code>babel<\/code> \u548c <code>rollup<\/code> \u5904\u7406 <code>js<\/code> \u6587\u4ef6\uff0c\u5165\u53e3\u6587\u4ef6 app.config.ts \uff0c\u8fd8\u5728\u5f00\u5934\u8ffd\u52a0\u4e86 <code>promise-ployfill<\/code> \uff0c\u4f7f\u7528 <code>postcss<\/code> \u5904\u7406\u6837\u5f0f\u6587\u4ef6\uff0c\u5176\u4ed6\u6587\u4ef6\u662f\u76f4\u63a5\u590d\u5236\u7c98\u8d34\u5230 <code>dist<\/code> \u76ee\u5f55\u7684\u3002<\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4\uff1a\u53ea\u662f<code>html<\/code>(<code>wxml<\/code>)\u6a21\u677f\u90e8\u5206\u8fd8\u662f\u539f\u751f\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5199\u6cd5\uff0c<code>ts<\/code>(<code>js<\/code>)\u903b\u8f91\u90e8\u5206\u4f7f\u7528\u4e86<code>vue-mini<\/code>\uff08\u8f7b\u8fd0\u884c\u65f6\uff09\u3002<\/p>\n<p>\u5e38\u8a00\u9053\uff1a\u4e00\u56fe\u80dc\u5343\u8a00\u3002\u6211\u753b\u4e86\u4e00\u5f20\u56fe\u8868\u793a\uff1a<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012246\" alt=\"vue-mini.drawio.png\" title=\"vue-mini.drawio.png\" loading=\"lazy\"><\/p>\n<p><code>vue-mini<\/code> \u6bd4\u8f83\u9002\u5408\u4e0d\u9700\u8981\u8de8\u7aef\uff0c\u6bd4\u5982\u4e0d\u9700\u8981\u540c\u65f6\u652f\u6301\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u548c\u652f\u4ed8\u5b9d\u5c0f\u7a0b\u5e8f\u3002\u53ea\u5f00\u53d1\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u662f\u4e00\u4e2a\u65b0\u9009\u62e9\uff0c\u6027\u80fd\u57fa\u672c\u7b49\u4e8e\u539f\u751f\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\uff0c\u903b\u8f91\u90e8\u5206\u5f00\u53d1\u4f53\u9a8c\u4f18\u4e8e\u539f\u751f\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u3002\u9002\u5408\u672c\u8eab\u5c31\u662f\u4f7f\u7528\u7684\u539f\u751f\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u7684\uff0c\u53ef\u4ee5\u6e10\u8fdb\u5f0f\u5347\u7ea7\u66ff\u6362\u4e3a <code>vue-mini<\/code>\u3002<\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4 <code>vue-mini<\/code> \u662f\u6e10\u8fdb\u5f0f\u5f00\u53d1\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u3002\u548c\u539f\u751f\u5f00\u53d1\u4e0d\u662f\u4e8c\u9009\u4e00\u3002\u6027\u80fd\u4e0a\uff0c<code>vue-mini<\/code> \u63a5\u8fd1\u539f\u751f\uff0c\u5f00\u53d1\u4f53\u9a8c\u4f18\u4e8e\u539f\u751f\u5f00\u53d1\u3002<\/p>\n<p>\u4e0d\u8fc7\u76ee\u524d\u8fd8\u5904\u4e8e\u76f8\u5bf9\u521d\u671f\u9636\u6bb5\uff0c\u751f\u6001\u8fd8\u4e0d\u662f\u5f88\u5b8c\u5584\uff0c\u6bd4\u5982\u6682\u4e0d\u652f\u6301 <code>less\u3001sass<\/code> \u7b49\u3002<\/p>\n<p><code>vue-mini<\/code> \u4f5c\u8005\u5728\u6700\u540e\u4e5f\u6709\u4e00\u9875\u63a5\u4e0b\u6765\u7684\u5f00\u53d1\u65b9\u5411\u7684PPT\u3002\u4f5c\u8005\u76ee\u524d\u65f6\u95f4\u548c\u7cbe\u529b\u6709\u9650\uff0c\u6ca1\u6709\u652f\u6301\u591a\u7aef\u7684\u6253\u7b97\u3002\u957f\u671f\u53ef\u80fd\u6709\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000046012247\" alt=\"vue-mini-next.png\" title=\"vue-mini-next.png\" loading=\"lazy\"><\/p>\n<p>\u611f\u5174\u8da3\u7684\u5c0f\u4f19\u4f34\u53ef\u4ee5<a href=\"https:\/\/link.segmentfault.com\/?enc=7OAJweFwhBeshVEJanMZ9Q%3D%3D.NCjxjYywY5J1fDQXMPnel2eYGaGdfuvGKVxwHwqV27WYuYxwcPgmfDvY9aSymBhz\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u70b9\u4e2a star<\/a>\u3002\u6211\u4eec\u6301\u7eed\u5173\u6ce8\u540e\u7eed\u53d1\u5c55\uff0c\u6709\u4f59\u529b\u7684\u5c0f\u4f19\u4f34\u4e5f\u53ef\u4ee5\u591a\u53c2\u4e0e\u8d21\u732e\u3002<\/p>\n<hr>\n<p><strong>\u5982\u679c\u770b\u5b8c\u6709\u6536\u83b7\uff0c\u6b22\u8fce\u70b9\u8d5e\u3001\u8bc4\u8bba\u3001\u5206\u4eab\u3001\u6536\u85cf\u652f\u6301\u3002\u4f60\u7684\u652f\u6301\u548c\u80af\u5b9a\uff0c\u662f\u6211\u5199\u4f5c\u7684\u52a8\u529b<\/strong>\u3002<\/p>\n<p>\u4f5c\u8005\uff1a\u5e38\u4ee5<strong>\u82e5\u5ddd<\/strong>\u4e3a\u540d\u6df7\u8ff9\u4e8e\u6c5f\u6e56\u3002\u6240\u77e5\u751a\u5c11\uff0c\u552f\u5584\u5b66\u3002<a href=\"https:\/\/link.segmentfault.com\/?enc=Y1ZVOhtKecoFxc6tr0dpYw%3D%3D.ZbRihjS3VYj6WKwGFF8lSbc%2FPGq3KG7yWO8mtDndyO8%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u82e5\u5ddd\u7684\u535a\u5ba2<\/a>\uff0c<a href=\"https:\/\/link.segmentfault.com\/?enc=N86c9h7N20BQsrSsTYDw7Q%3D%3D.nelvVn3EFGgXVcU7Kr2VK1vWw2Y4%2F2fiQz%2F4yq%2Bo15EjS37JV0DNxovPH7JRdaCG\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">github blog<\/a>\uff0c\u53ef\u4ee5\u70b9\u4e2a <code>star<\/code> \u9f13\u52b1\u4e0b\u6301\u7eed\u521b\u4f5c\u3002<\/p>\n<p>\u6700\u540e\u53ef\u4ee5\u6301\u7eed\u5173\u6ce8\u6211<a href=\"https:\/\/link.segmentfault.com\/?enc=F0femLgewhYkYKlCF1PZLg%3D%3D.73PWjai9eiCUxdkmC2AAeZnLaWsfok4YAfNpglp9pGPrrUwV5paKEOg4%2FR9TNZ7p\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@\u82e5\u5ddd<\/a>\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684<a href=\"https:\/\/link.segmentfault.com\/?enc=ocWRxx6ykiEaanqhwjFpcw%3D%3D.K2JBFvJn9hMWjY54zSbwLShGy8R8M22jXnB0C%2FG2iq0n%2FT4JmEKyme8vUA54lxDzq8JdwcJbjjdKopyng2N3eQ%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u516c\u4f17\u53f7\uff1a\u82e5\u5ddd\u89c6\u91ce<\/a>\u3002\u6211\u503e\u529b\u6301\u7eed\u7ec4\u7ec7\u4e86 3 \u5e74\u591a<a href=\"https:\/\/link.segmentfault.com\/?enc=fZjTZ0GBPqR0qXf%2FLcYCRA%3D%3D.sMQ4WBRaleVBSnswEK35Q%2BtK4CLEIcxYeRgPiTm6oAj4zLo%2B77iwBMsW7Rru8oee\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u6bcf\u5468\u5927\u5bb6\u4e00\u8d77\u5b66\u4e60 200 \u884c\u5de6\u53f3\u7684\u6e90\u7801\u5171\u8bfb\u6d3b\u52a8<\/a>\uff0c\u611f\u5174\u8da3\u7684\u53ef\u4ee5<a href=\"https:\/\/link.segmentfault.com\/?enc=rspBNfSLFXVej%2BRKI%2F2atw%3D%3D.S53YlWNIyGtvNWfZd%2BB0tKz7sgGcuGsNfQdqbCRr%2Fyb73%2Bbrhdvx%2F6zd2W9m0QVX\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u70b9\u6b64\u626b\u7801\u52a0\u6211\u5fae\u4fe1 <code>ruochuan02<\/code> \u53c2\u4e0e<\/a>\u3002\u53e6\u5916\uff0c\u60f3\u5b66\u6e90\u7801\uff0c\u6781\u529b\u63a8\u8350\u5173\u6ce8\u6211\u5199\u7684\u4e13\u680f<a href=\"https:\/\/link.segmentfault.com\/?enc=fugnQlwC7pnw3iQO4JacIQ%3D%3D.deOvsE5VEJTuRE1IA2Fb7AfUY9NqNfhvAid0FIuyKVOAPLSGzsOFco6rJyn1RNj2\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">\u300a\u5b66\u4e60\u6e90\u7801\u6574\u4f53\u67b6\u6784\u7cfb\u5217\u300b<\/a>\uff0c\u76ee\u524d\u662f\u6398\u91d1\u5173\u6ce8\u4eba\u6570\uff086k+\u4eba\uff09\u7b2c\u4e00\u7684\u4e13\u680f\uff0c\u5199\u6709\u51e0\u5341\u7bc7\u6e90\u7801\u6587\u7ae0\u3002<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000046012229\">https:\/\/segmentfault.com\/a\/1190000046012229<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u524d\u8a00 \u5927\u5bb6\u597d\uff0c\u6211\u662f\u82e5\u5ddd\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u516c\u4f17\u53f7\uff1a\u82e5\u5ddd\u89c6\u91ce\u3002\u6211\u503e\u529b\u6301\u7eed\u7ec4\u7ec7\u4e86 3 \u5e74\u591a\u6bcf\u5468\u5927\u5bb6\u4e00\u8d77\u5b66\u4e60 200 [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10020612","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020612","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10020612"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020612\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10020612"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10020612"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10020612"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}