{"id":52,"date":"2018-10-16T10:10:47","date_gmt":"2018-10-16T02:10:47","guid":{"rendered":"http:\/\/39.105.95.215\/?p=52"},"modified":"2018-10-22T10:09:06","modified_gmt":"2018-10-22T02:09:06","slug":"%e6%a8%a1%e5%9d%97%e5%bc%80%e5%8f%91%e4%b9%8bwebpack%e6%9f%a5%e7%9c%8b%e6%97%a5%e5%bf%97%e5%b7%a5%e5%85%b7webpack-dashboard%e5%92%8cjarvis","status":"publish","type":"post","link":"https:\/\/adeqing.com\/index.php\/2018\/10\/16\/develop\/webpack\/52\/","title":{"rendered":"\u6a21\u5757\u5f00\u53d1\u4e4bwebpack\u67e5\u770b\u65e5\u5fd7\u5de5\u5177webpack-dashboard\u548cjarvis"},"content":{"rendered":"<p>\u524d\u8a00<br \/>\n\u6211\u4eec\u77e5\u9053webpack\u7f16\u8bd1\u9636\u6bb5\u6253\u5370\u51fa\u6765\u7684\u65e5\u5fd7\u4e00\u822c\u4eba\u662f\u770b\u4e0d\u61c2\u7684\u3002\u5982\u679c\u6709\u4e2a\u5de5\u5177\u80fd\u7edf\u8ba1\u8fd9\u4e9b\u4fe1\u606f\u8ba9\u7a0b\u5e8f\u5458\u770b\u61c2\u5c31\u597d\u4e86\uff0c\u4e0b\u9762\u6709\u51e0\u4e2a\u5de5\u5177\uff0c\u53ef\u4ee5\u8bf4\u662f\u67e5\u770bwebpack\u7f16\u8bd1\u60c5\u51b5\u7684\u5229\u5668\u3002<\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5<br \/>\n\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u901a\u8fc7\u5728webpack-dev-server\u547d\u4ee4\u540e\u6dfb\u52a0&#8211;progress &#8211;colors\u9009\u9879\u53ef\u4ee5\u67e5\u770bwebpack\u7f16\u8bd1\u8fdb\u5ea6\u3002<br \/>\n\u547d\u4ee4\u7c7b\u4f3c\u4e0b\u9762<\/p>\n<blockquote><p>&#8220;scripts&#8221;: {<br \/>\n&#8220;webpack-dev-server &#8211;config webpack.dev.config.js &#8211;mode development &#8211;devtool eval-source-map &#8211;progress &#8211;colors&#8221;<br \/>\n}<\/p><\/blockquote>\n<p>\u6253\u5370\u51fa\u4e00\u4e32\u6587\u4ef6\uff0c\u4e00\u822c\u4eba\u5f88\u96be\u770b\u61c2\uff0c\u968f\u7740\u9879\u76ee\u53d8\u5927\uff0c\u7f16\u8bd1\u7684\u5de5\u4f5c\u91cf\u589e\u52a0\uff0c\u5c31\u66f4\u590d\u6742\u4e86\u3002<\/p>\n<h1 id=\"webpack-dashboard\">webpack-dashboard<\/h1>\n<p>\u53c2\u6570<a href=\"https:\/\/github.com\/FormidableLabs\/webpack-dashboard\" target=\"_blank\" rel=\"nofollow noopener\">FormidableLabs\/webpack-dashboard<\/a><br \/>\n<code>webpack-dashboard<\/code>\u662f\u4e00\u7edf\u8ba1\u548c\u4f18\u5316webpack\u65e5\u5fd7\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u4ee5\u8868\u683c\u5f62\u52bf\u5c55\u793a\u65e5\u5fd7\u4fe1\u606f\u3002\u5176\u4e2d\u5305\u62ec\u6784\u5efa\u8fc7\u7a0b\u548c\u72b6\u6001\u3001\u65e5\u5fd7\u4ee5\u53ca\u6d89\u53ca\u7684\u6a21\u5757\u5217\u8868\u3002<\/p>\n<p>\u4e0b\u9762\u4ee5webpack-dev-server\u65b9\u5f0f\u542f\u52a8\u670d\u52a1\u4e3a\u4f8b\u3002<br \/>\n\u4f7f\u7528\u8d77\u6765\u5f88\u7b80\u5355\uff0c\u53ea\u8981\u6dfb\u52a0\u63d2\u4ef6\u5373\u53ef\u3002<\/p>\n<p>\u4e0b\u9762\u4ee5<code>webpack-dev-server<\/code>\u65b9\u5f0f\u542f\u52a8\u670d\u52a1\u4e3a\u4f8b\u3002<br \/>\n\u4f7f\u7528\u8d77\u6765\u5f88\u7b80\u5355\uff0c\u53ea\u8981\u6dfb\u52a0\u63d2\u4ef6\u5373\u53ef\u3002<\/p>\n<h2 id=\"\u5b89\u88c5\u6a21\u5757\">\u5b89\u88c5\u6a21\u5757<\/h2>\n<blockquote>\n<pre class=\"prettyprint\"><code class=\"hljs lasso has-numbering\">npm install webpack<span class=\"hljs-attribute\">-dashboard<\/span> <span class=\"hljs-subst\">--<\/span>save<span class=\"hljs-attribute\">-dev<\/span><\/code><\/pre>\n<\/blockquote>\n<h2 id=\"\u5728webpackconfigjs\u91cc\u6dfb\u52a0\u63d2\u4ef6\">\u5728webpack.config.js\u91cc\u6dfb\u52a0\u63d2\u4ef6<\/h2>\n<blockquote>\n<pre class=\"prettyprint\"><code class=\"hljs javascript has-numbering\"><span class=\"hljs-comment\">\/\/\u5bfc\u5165\u6a21\u5757<\/span>\r\n<span class=\"hljs-keyword\">var<\/span> DashboardPlugin = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'webpack-dashboard\/plugin'<\/span>);\r\n\r\n<span class=\"hljs-comment\">\/\/\u6dfb\u52a0\u63d2\u4ef6<\/span>\r\nplugins: [\r\n    <span class=\"hljs-keyword\">new<\/span> DashboardPlugin()\r\n]<\/code><\/pre>\n<p>\u5bf9\uff0c\u53ea\u8981\u8fd9\u4e9b\u914d\u7f6e\u5c31\u53ef\u4ee5\u4e86\u3002<br \/>\n<code>webpack-dashboard<\/code>\u63d2\u4ef6\u4f7f\u7528socket\u8fde\u63a5\u65b9\u5f0f\u8fde\u63a5<code>webpack-dev-server<\/code>\u542f\u52a8\u7684\u670d\u52a1\u3002\u6240\u4ee5\u5b83\u80fd\u5b9e\u65f6\u76d1\u542c\u3002<\/p><\/blockquote>\n<h2 id=\"\u53ef\u9009\u53c2\u6570\">\u53ef\u9009\u53c2\u6570<\/h2>\n<p><code>DashboardPlugin<\/code>\u6709\u51e0\u4e2a\u53ef\u9009\u53c2\u6570\u3002<\/p>\n<ul>\n<li><code>port<\/code>:\u6307\u5b9a\u8fde\u63a5socket\u5ba2\u6237\u7aef\u7684\u7aef\u53e3<\/li>\n<li><code>host<\/code>:\u6307\u5b9a\u8fde\u63a5socket\u5ba2\u6237\u7aef\u7684\u57df\u540d<\/li>\n<li><code>handler<\/code>:\u63d2\u4ef6\u7684\u5904\u7406\u65b9\u6cd5<br \/>\n\u56e0\u4e3a\u6709handler\uff0c\u6240\u4ee5\u8fd8\u53ef\u4ee5\u5982\u4e0b\u4f7f\u7528<\/li>\n<\/ul>\n<blockquote><p>\/\/\u5f15\u5165\u6a21\u5757<br \/>\nvar Dashboard = require(&#8216;webpack-dashboard&#8217;);<br \/>\nvar DashboardPlugin = require(&#8216;webpack-dashboard\/plugin&#8217;);<br \/>\nvar dashboard = new Dashboard();<\/p>\n<p>\/\/\u6dfb\u52a0\u63d2\u4ef6\u65b9\u6cd5<br \/>\nnew DashboardPlugin(dashboard.setData)<\/p><\/blockquote>\n<p>\u5982\u679c\u4f7f\u7528<code>webpack-dashboard<\/code>\uff0c\u63a8\u8350\u4f7f\u7528\u8fd9\u79cd\u65b9\u5f0f\u3002<\/p>\n<h2 id=\"\u7f3a\u70b9\">\u7f3a\u70b9<\/h2>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u867d\u7136\u597d\uff0c\u4f46\u7531\u4e8e\u5728dos\u9762\u677f\u4e0a\u5c55\u793a\u7684\uff0cdos\u9762\u677f\u5fc5\u9700\u8981\u5927\u624d\u80fd\u770b\u7684\u6e05\u695a\uff0c\u7535\u8111\u5206\u8fa8\u7387\u8981\u9ad8\uff0c\u4e0d\u7136\u5c55\u793a\u4e0d\u5168\uff0c\u770b\u8d77\u6765\u66f4\u522b\u626d\u3002\u540c\u65f6\u7edf\u8ba1\u7684\u4fe1\u606f\u4e5f\u4e0d\u662f\u5f88\u5168\u3002\u6240\u4ee5\u6211\u63a8\u8350\u4e0b\u9762\u7684\u65b9\u5f0f<code>jarvis<\/code>\u3002<\/p>\n<p>&nbsp;<\/p>\n<h1 id=\"jarvis\">jarvis<\/h1>\n<p>\u5b83\u662f\u5728\u6d4f\u89c8\u5668\u91cc\u5c55\u793a\u7684\uff0c\u6240\u4ee5\u5b83\u7684\u81ea\u9002\u5e94\u6548\u679c\u505a\u7684\u597d\uff0c\u770b\u7684\u6e05\u695a\u3002\u540c\u65f6\uff0c\u5b83\u7edf\u8ba1\u7684\u4fe1\u606f\u4e5f\u6bd4\u8f83\u591a\u3002<br \/>\njarvis\u662fJust A Rather Very Intelligent System\u9996\u5b57\u6bcd\u7f29\u5199\uff0c\u610f\u601d\u662f\u5b83\u662f\u4e00\u4e2a\u975e\u5e38\u806a\u660e\u7684\u7cfb\u7edf\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u6d4f\u89c8\u5668\u5c55\u793a\u7ed3\u679c\uff0c\u5b83\u80fd\u6536\u96c6webpack\u7f16\u8bd1\u6216\u8005\u8fd0\u884c\u9636\u6bb5\u7684\u4fe1\u606f\u3002<\/p>\n<p>\u4f18\u70b9<br \/>\n\u754c\u9762\u7f8e\u89c2<br \/>\n\u8fd0\u884c\u5728\u6d4f\u89c8\u5668\u91cc<br \/>\n\u5f88\u65b9\u4fbf\u67e5\u770b\u8d44\u6e90\u5927\u5c0f<br \/>\n\u9519\u8bef\u63d0\u793a\u505a\u7684\u975e\u5e38\u597d<\/p>\n<p>&nbsp;<\/p>\n<blockquote><p>\u5b89\u88c5\u6a21\u5757<br \/>\nnpm i -D webpack-jarvis<\/p><\/blockquote>\n<p>\u5728webpack.config.js\u914d\u7f6e\u63d2\u4ef6<\/p>\n<blockquote><p>\/\/\u5f15\u5165\u6a21\u5757<br \/>\nconst Jarvis = require(&#8220;webpack-jarvis&#8221;);<\/p>\n<p>\/* the rest of your webpack configs *\/<br \/>\n\/\/\u6dfb\u52a0\u63d2\u4ef6\uff0c\u6307\u5b9a\u76d1\u542c\u7aef\u53e3\u662f1337<br \/>\nplugins: [<br \/>\nnew Jarvis({<br \/>\nport: 1337 \/\/ optional: set a port<br \/>\n})<br \/>\n]<\/p><\/blockquote>\n<h2 id=\"\u67e5\u770b\u6548\u679c\">\u67e5\u770b\u6548\u679c<\/h2>\n<p>\u542f\u52a8\u7f16\u8bd1<code>npm start<\/code>\u6216<code>npm run dev<\/code>\uff08\u8fd9\u4e9b\u547d\u4ee4\u5728package.json\u7684scripts\u914d\u7f6e\u7684\uff09\u3002<br \/>\n\u8bbf\u95ee<code>http:\/\/localhost:1337\/<\/code>\u5373\u80fd\u770b\u5230\u597d\u770b\u7684\u3001\u7f8e\u4e3d\u7684\u754c\u9762\u4e86\u3002<\/p>\n<h2><\/h2>\n<h2>\u53ef\u9009\u53c2\u6570<br \/>\njarvis\u63d0\u4f9b\u4e86\u4e00\u4e9b\u53ef\u9009\u53c2\u6570\u4f9b\u81ea\u5b9a\u4e49<\/h2>\n<blockquote><p>port:\u76d1\u542c\u7684\u7aef\u53e3\uff0c\u9ed8\u8ba41337\uff0c\u76d1\u542c\u9762\u677f\u5c06\u76d1\u542c\u8fd9\u4e2a\u7aef\u53e3\uff0c\u901a\u5e38\u50cfhttp:\/\/localhost:port\/<br \/>\nhost:\u57df\u540d\uff0c\u9ed8\u8ba4localhost,\u4e5f\u53ef\u4ee5\u8bbe\u4e3a0.0.0.0\uff0c\u4e0d\u9650\u5236\u57df\u540d\u3002<br \/>\nwatchOnly:\u4ec5\u4ec5\u76d1\u542c\u7f16\u8bd1\u9636\u6bb5\u3002\u9ed8\u8ba4\u4e3atrue,\u5982\u679c\u9ad8\u4e3afalse\uff0cjarvis\u4e0d\u4ec5\u4ec5\u8fd0\u884c\u5728\u7f16\u8bd1\u9636\u6bb5\uff0c\u5728\u7f16\u8bd1\u5b8c\u6210\u540e\u8fd8\u4fdd\u6301\u8fd0\u884c\u72b6\u6001\u3002<\/p>\n<p>\u6bd4\u5982<\/p>\n<p>new Jarvis({<br \/>\nhost: 0.0.0.0<br \/>\n})<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u6211\u4eec\u77e5\u9053webpack\u7f16\u8bd1\u9636\u6bb5\u6253\u5370\u51fa\u6765\u7684\u65e5\u5fd7\u4e00\u822c\u4eba\u662f\u770b\u4e0d\u61c2\u7684\u3002\u5982\u679c\u6709\u4e2a\u5de5\u5177\u80fd\u7edf\u8ba1\u8fd9\u4e9b\u4fe1\u606f\u8ba9\u7a0b\u5e8f\u5458\u770b\u61c2\u5c31\u597d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,5],"tags":[],"_links":{"self":[{"href":"https:\/\/adeqing.com\/index.php\/wp-json\/wp\/v2\/posts\/52"}],"collection":[{"href":"https:\/\/adeqing.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adeqing.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adeqing.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/adeqing.com\/index.php\/wp-json\/wp\/v2\/comments?post=52"}],"version-history":[{"count":5,"href":"https:\/\/adeqing.com\/index.php\/wp-json\/wp\/v2\/posts\/52\/revisions"}],"predecessor-version":[{"id":58,"href":"https:\/\/adeqing.com\/index.php\/wp-json\/wp\/v2\/posts\/52\/revisions\/58"}],"wp:attachment":[{"href":"https:\/\/adeqing.com\/index.php\/wp-json\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adeqing.com\/index.php\/wp-json\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adeqing.com\/index.php\/wp-json\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}