{"id":333,"date":"2022-01-05T15:07:46","date_gmt":"2022-01-05T07:07:46","guid":{"rendered":"http:\/\/gjweb.top\/?p=333"},"modified":"2022-01-05T15:07:47","modified_gmt":"2022-01-05T07:07:47","slug":"3-%e7%bc%96%e8%af%91%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=333","title":{"rendered":"3. \u7f16\u8bd1&amp;\u914d\u7f6e\u6587\u4ef6"},"content":{"rendered":"\n<ol class=\"wp-block-list\"><li>\u7f16\u8bd1<ol start=\"\"><li>\u52a8\u6001\u7f16\u8bd1&amp;\u70ed\u66f4\u65b0<\/li><li>\u5e76\u884c\u7f16\u8bd1<\/li><\/ol><\/li><li>\u914d\u7f6e\u6587\u4ef6<\/li><\/ol>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u7f16\u8bd1<\/h2>\n\n\n\n<p>\u7f16\u8bd1 package.json<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{<br> &nbsp; &nbsp;\"scripts\":{<br> &nbsp; &nbsp; &nbsp; &nbsp;\"dev\":\"ts-node &#91;\u9700\u8981\u8fd0\u884c\u7684\u6587\u4ef6\u8def\u5f84].ts\",<br> &nbsp; &nbsp; &nbsp; &nbsp;\"build\":\"tsc\", \/\/ \u6253\u5305<br> &nbsp;  }<br>}<\/code><\/pre>\n\n\n\n<p>\u6253\u5305\u5230\u6307\u5b9a\u6587\u4ef6\u5939 tsconfig.json<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"outDir\":\".\/build\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u52a8\u6001\u7f16\u8bd1&amp;\u70ed\u66f4\u65b0<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install nodemon -D<br>\/\/ nodemon \u9ed8\u8ba4\u53ea\u4f1a\u76d1\u542c.js\u6587\u4ef6\u7684\u53d8\u5316<\/code><\/pre>\n\n\n\n<p>package.json<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{<br> &nbsp; &nbsp;\"scripts\":{<br> &nbsp; &nbsp; &nbsp; &nbsp;\"build\":\"tsc -w\",<br> &nbsp; &nbsp; &nbsp; &nbsp;\"start\":\"nodemon node &#91;\u9700\u8981\u8fd0\u884c\u7684js\u6587\u4ef6\u8def\u5f84].js\" \/\/ \u8868\u793a\u53ea\u8981js\u6587\u4ef6\u53d1\u751f\u53d8\u5316,\u5c06\u4f1a\u81ea\u52a8\u8fd0\u884c<br> &nbsp;  },<br> &nbsp; &nbsp;\"nodemonConfig\":{<br> &nbsp; &nbsp; &nbsp; &nbsp;\"ignore\":&#91;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"data\/*\" \/\/ \u8868\u793a\u8be5\u6587\u4ef6\u5939\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u5ffd\u7565\u53d8\u5316<br> &nbsp; &nbsp; &nbsp;  ]<br> &nbsp;  }<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5e76\u884c\u7f16\u8bd1<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install concurrently -D<\/code><\/pre>\n\n\n\n<p>package.json<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{<br> &nbsp; &nbsp;\"scripts\":{<br> &nbsp; &nbsp; &nbsp; &nbsp;\"dev:build\":\"tsc -w\",<br> &nbsp; &nbsp; &nbsp; &nbsp;\"dev:start\":\"nodemon node &#91;\u9700\u8981\u8fd0\u884c\u7684js\u6587\u4ef6\u8def\u5f84].js\",<br> &nbsp; &nbsp; &nbsp; &nbsp;\"dev\":\"concurrently npm:dev:*\" \/\/ \u5e76\u884c\u6267\u884cdev:\u540e\u9762\u7684\u547d\u4ee4<br> &nbsp;  }<br>}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u914d\u7f6e\u6587\u4ef6<\/h2>\n\n\n\n<p>tsconfig.json<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{<br> &nbsp; &nbsp;\"include\": &#91;\".\/demo.ts\"], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/*\u9700\u8981\u7f16\u8bd1\u7684Ts\u6587\u4ef6(\u9ed8\u8ba4\u76ee\u6807\u662f\u6839\u76ee\u5f55)*\/<br>    \"exclude\": &#91;\".\/demo1.ts\"], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/*\u7f16\u8bd1\u9664\u8be5\u9879\u4e4b\u5916\u7684ts\u6587\u4ef6(\u9ed8\u8ba4\u76ee\u6807\u662f\u6839\u76ee\u5f55)*\/<br> &nbsp; &nbsp;\"files\":&#91;\".\/demo.ts\"] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/*\u4f5c\u7528\u548cinclude\u76f8\u540c*\/<br>    \"compilerOptions\":{<br> &nbsp;      \"removeComments\":true, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/*\u7f16\u8bd1\u65f6\u8fc7\u6ee4\u6389\u6ce8\u91ca*\/<br> &nbsp;      \"noImplicitAny\":false, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/*\u4e0d\u8981\u6c42\u5f3a\u5236\u4e66\u5199any\u7c7b\u578b,(\u8fdb\u884c\u7c7b\u578b\u63a8\u65ad\u4e0d\u4f1a\u63d0\u793a\u8bed\u6cd5\u9519\u8bef)*\/<br> &nbsp;      \"strictNullChecks\":false, &nbsp; &nbsp; &nbsp; \/*\u4e0d\u5f3a\u5236\u8fdb\u884cnull\u6821\u9a8c,(\u5173\u95ed\u540enull\u7c7b\u578b\u53ef\u4ee5\u8d4b\u503c\u5230\u4efb\u610f\u7c7b\u578b\u4e2d)*\/<br> &nbsp;      \"rootDir\":\".\/src\", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/*\u6307\u5b9a\u7f16\u8bd1\u7684\u6587\u4ef6\u5730\u5740*\/<br> &nbsp;      \"outDir\":\".\/build\", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/*\u6307\u5b9a\u7f16\u8bd1\u540e\u7684\u6587\u4ef6\u5730\u5740*\/<br> &nbsp;      \"incremental\":true, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/*\u589e\u91cf\u7f16\u8bd1(\u76f4\u63a5\u6dfb\u52a0\u65b0\u589e\u53d8\u5316\u7684\u7f16\u8bd1\u5185\u5bb9,\u7c7b\u4f3c\u4e8ediff\u7b97\u6cd5)*\/<br> &nbsp;      \"allowJs\":true, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/*\u5c06.js\u6587\u4ef6\u8fdb\u884c\u7f16\u8bd1,\u7f16\u8bd1\u6210target\u7684\u76ee\u6807\u8bed\u6cd5*\/<br> &nbsp;      \"checkJS\":true, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/*\u68c0\u6d4bjs\u8bed\u6cd5*\/<br> &nbsp;      \"sourceMap\":true, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/*\u6253\u5305\u65f6\u751f\u6210\u6587\u4ef6\u7684sourceMap?*\/<br> &nbsp;      \"noUnusedLocals\":true, &nbsp; &nbsp; &nbsp; &nbsp; \/*\u68c0\u67e5\u672a\u4f7f\u7528\u7684\u53d8\u91cf*\/<br> &nbsp;      \"noUnusedParameters\":true, &nbsp; &nbsp; \/*\u6821\u9a8c\u51fd\u6570\u4e2d\u672a\u4f7f\u7528\u7684\u53c2\u6570*\/<br>    }<br>}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u5c06\u591a\u4e2ats\u6587\u4ef6\u6253\u5305\u5230\u4e00\u4e2a\u6587\u4ef6\u91cc\u9762<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>{<br> &nbsp; &nbsp;\"compilerOptions\":{<br> &nbsp; &nbsp; &nbsp; &nbsp;\"outFile\":\".\/build\/page.js\",<br> &nbsp; &nbsp; &nbsp; &nbsp;\"module\":\"amd\"<br> &nbsp;  }<br>}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7f16\u8bd1 \u52a8\u6001\u7f16\u8bd1&amp;\u70ed\u66f4\u65b0 \u5e76\u884c\u7f16\u8bd1 \u914d\u7f6e\u6587\u4ef6 \u7f16\u8bd1 \u7f16\u8bd1 package.json \u6253\u5305\u5230\u6307\u5b9a\u6587\u4ef6\u5939 t [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-333","post","type-post","status-publish","format-standard","hentry","category-typescript"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=333"}],"version-history":[{"count":0,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/333\/revisions"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}