{"id":308353,"date":"2020-08-12T09:00:31","date_gmt":"2020-08-12T09:00:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=308353"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-08-12T09:00:31","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=308353","title":{"rendered":"Webpack: \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/514838\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/k-\/tm\/2g\/k-tm2gvbb_ky6gdrd-tzqrzjkf4.png\"><\/p>\n<p>  \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0434\u0440\u0443\u0437\u044c\u044f! <\/p>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/ui.dev\/webpack\/\" rel=\"nofollow\">\u00abWebpack: A gentle introduction\u00bb<\/a> \u0430\u0432\u0442\u043e\u0440\u0430 Tyler McGinnis. <\/p>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0437\u0430\u0434\u0430\u0439\u0442\u0435 \u0441\u0435\u0431\u0435 \u0434\u0432\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u0430:<\/p>\n<ol>\n<li>\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d \u044d\u0442\u043e\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442?<\/li>\n<li>\u041a\u0430\u043a\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442?<\/li>\n<\/ol>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0438\u0437\u0443\u0447\u0430\u0435\u043c\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a Webpack.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d \u0432\u0435\u0431\u043f\u0430\u043a?<\/h3>\n<p>  \u0412\u0435\u0431\u043f\u0430\u043a \u2014 \u044d\u0442\u043e \u0441\u0431\u043e\u0440\u0449\u0438\u043a \u043c\u043e\u0434\u0443\u043b\u0435\u0439. \u041e\u043d \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0433\u0440\u0430\u0444 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u0438 \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432 \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0431\u0430\u043d\u0434\u043b (bundle), \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u0444\u0430\u0439\u043b \u00abindex.html\u00bb. <\/p>\n<pre><code class=\"javascript\">App.js -&gt;       | Dashboard.js -&gt; | Bundler | -&gt; bundle.js About.js -&gt;     | <\/code><\/pre>\n<p>  <\/p>\n<h3>\u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0440\u0435\u0448\u0430\u0435\u0442 \u0432\u0435\u0431\u043f\u0430\u043a?<\/h3>\n<p>  \u041e\u0431\u044b\u0447\u043d\u043e, \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 JavaScript, \u043a\u043e\u0434 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u0435\u0439 (\u043c\u043e\u0434\u0443\u043b\u0435\u0439). \u0417\u0430\u0442\u0435\u043c \u0432 \u0444\u0430\u0439\u043b\u0435 \u00abindex.html\u00bb \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442. <\/p>\n<pre><code class=\"xml\">&lt;body&gt;      ...          &lt;script src=&quot;http:\/\/cdnjs.cloudflare.com\/ajax\/libs\/jquery\/2.1.4\/jquery.min.js&quot;&gt;&lt;\/script&gt;     &lt;script src=&quot;libs\/react.min.js&quot;&gt;&lt;\/script&gt;     &lt;script src='src\/admin.js'&gt;&lt;\/script&gt;     &lt;script src='src\/dashboard.js'&gt;&lt;\/script&gt;     &lt;script src='src\/api.js'&gt;&lt;\/script&gt;     &lt;script src='src\/auth.js'&gt;&lt;\/script&gt;     &lt;script src='src\/rickastley.js'&gt;&lt;\/script&gt; &lt;\/body&gt; <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u0438 \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d\u043e \u043e\u0448\u0438\u0431\u043a\u0430\u043c. \u0412\u0430\u0436\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0441\u043a\u0440\u0438\u043f\u0442, \u043d\u043e \u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0438\u0445 \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u0415\u0441\u043b\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442, \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0438\u0439 \u043e\u0442 React, \u0434\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0430\u043c\u043e\u0433\u043e React, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f. \u0412\u0435\u0431\u043f\u0430\u043a \u0440\u0435\u0448\u0430\u0435\u0442 \u044d\u0442\u0438 \u0437\u0430\u0434\u0430\u0447\u0438. \u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u044c\u0441\u044f \u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432. <\/p>\n<pre><code class=\"xml\">&lt;body&gt;      ...          &lt;script src='dist\/bundle.js'&gt;&lt;\/script&gt; &lt;\/body&gt; <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0441\u043a\u043e\u0440\u043e \u0443\u0437\u043d\u0430\u0435\u043c, \u0441\u0431\u043e\u0440 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0435\u0431\u043f\u0430\u043a\u0430. \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0435\u0431\u043f\u0430\u043a \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043f\u0435\u0440\u0435\u0434 \u0438\u0445 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0432 \u0431\u0430\u043d\u0434\u043b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 SASS\/LESS \u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 CSS, \u0438\u043b\u0438 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e JavaScript \u0432 ES5 \u0434\u043b\u044f \u0441\u0442\u0430\u0440\u044b\u0445 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u0432. <\/p>\n<h3>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0432\u0435\u0431\u043f\u0430\u043a\u0430<\/h3>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e npm, \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0435\u0431\u043f\u0430\u043a\u0430 \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0432\u0430 \u043f\u0430\u043a\u0435\u0442\u0430 \u2014 <code>webpack<\/code> \u0438 <code>webpack-cli<\/code>. <\/p>\n<pre><code class=\"javascript\">npm i webpack webpack-cli -D <\/code><\/pre>\n<p>  <\/p>\n<h3>webpack.config.js<\/h3>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u0432\u0435\u0431\u043f\u0430\u043a \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b <code>webpack.config.js<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442. \u042d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u0435\u0431\u043f\u0430\u043a\u0430. <\/p>\n<pre><code class=\"javascript\">module.exports = {} <\/code><\/pre>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0432\u0435\u0431\u043f\u0430\u043a\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0438\u0445 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0431\u0430\u043d\u0434\u043b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0435\u0431\u043f\u0430\u043a\u0443 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u0442\u0440\u0438 \u0432\u0435\u0449\u0438: <\/p>\n<ol>\n<li>\u0422\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/li>\n<li>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c<\/li>\n<li>\u041c\u0435\u0441\u0442\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0431\u0430\u043d\u0434\u043b<\/li>\n<\/ol>\n<p>  <\/p>\n<h3>\u0422\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430<\/h3>\n<p>  \u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430. \u042d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435. \u041e\u0431\u044b\u0447\u043d\u043e, \u0442\u0430\u043a\u0438\u043c \u0444\u0430\u0439\u043b\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f index.js. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a: <\/p>\n<pre><code class=\"javascript\">index.js   imports about.js   imports dashboard.js     imports graph.js     imports auth.js       imports api.js <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0441\u043e\u043e\u0431\u0449\u0438\u043c \u0432\u0435\u0431\u043f\u0430\u043a\u0443 \u043f\u0443\u0442\u044c \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0435\u0433\u043e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0433\u0440\u0430\u0444\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>entry<\/code> \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u0435\u0431\u043f\u0430\u043a\u0430 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0443\u0442\u0438 \u043a \u0433\u043b\u0430\u0432\u043d\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443: <\/p>\n<pre><code class=\"javascript\">module.exports = {     entry: '.\/app\/index.js' } <\/code><\/pre>\n<p>  <\/p>\n<h3>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043b\u043e\u0430\u0434\u0435\u0440\u043e\u0432 (loaders)<\/h3>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u0432\u0435\u0431\u043f\u0430\u043a\u0443 \u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0431\u0430\u043d\u0434\u043b\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043b\u043e\u0430\u0434\u0435\u0440\u044b. <\/p>\n<p>  \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 <code>import \/ require()<\/code> \u0432\u0435\u0431\u043f\u0430\u043a \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e JavaScript \u0438 JSON-\u0444\u0430\u0439\u043b\u044b. <\/p>\n<pre><code class=\"javascript\">import auth from '.\/api\/auth' \/\/  import config from '.\/utils\/config.json' \/\/  import '.\/styles.css' \/\/ \ufe0f import logo from '.\/assets\/logo.svg' \/\/ \ufe0f <\/code><\/pre>\n<p>  \u0415\u0434\u0432\u0430 \u043b\u0438 \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0432\u044b \u0440\u0435\u0448\u0438\u0442\u0435\u0441\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c\u0441\u044f JS \u0438 JSON-\u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0432\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0441\u0442\u0438\u043b\u0438, SVG, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0442.\u0434. \u0412\u043e\u0442 \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u044b \u043b\u043e\u0430\u0434\u0435\u0440\u044b. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043b\u043e\u0430\u0434\u0435\u0440\u043e\u0432, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437 \u0438\u0445 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0435\u0431\u043f\u0430\u043a\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 JS \u0438 JSON-\u0444\u0430\u0439\u043b\u0430\u043c\u0438. <\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043b\u043e\u0430\u0434\u0435\u0440. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c SVG, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e npm \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c svg-loader. <\/p>\n<pre><code class=\"javascript\">npm i svg-inline-loader -D  <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u0435\u0431\u043f\u0430\u043a\u0430. \u0412\u0441\u0435 \u043b\u043e\u0430\u0434\u0435\u0440\u044b \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 <code>module.rules<\/code>: <\/p>\n<pre><code class=\"javascript\">module.exports = {     entry: '.\/app\/index.js',     module: {         rules: []     } } <\/code><\/pre>\n<p>  \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043b\u043e\u0430\u0434\u0435\u0440\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0447\u0430\u0441\u0442\u0435\u0439. \u041f\u0435\u0440\u0432\u0430\u044f \u2014 \u0442\u0438\u043f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 (<code>.svg<\/code> \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435). \u0412\u0442\u043e\u0440\u0430\u044f \u2014 \u043b\u043e\u0430\u0434\u0435\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 (<code>svg-inline-loader<\/code> \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435). <\/p>\n<pre><code class=\"javascript\">module.exports = {   entry: '.\/app\/index.js',   module: {     rules: [       { test: \/\\.svg$\/, use: 'svg-inline-loader' }     ]   } } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c SVG-\u0444\u0430\u0439\u043b\u044b. \u041d\u043e \u0447\u0442\u043e \u043d\u0430\u0441\u0447\u0435\u0442 \u043d\u0430\u0448\u0438\u0445 CSS-\u0444\u0430\u0439\u043b\u043e\u0432? \u0414\u043b\u044f \u0441\u0442\u0438\u043b\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>css-loader<\/code>. <\/p>\n<pre><code class=\"javascript\">npm i css-loader -D  <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"javascript\">module.exports = {   entry: '.\/app\/index.js',   module: {     rules: [       { test: \/\\.svg$\/, use: 'svg-inline-loader' },       { test: \/\\.css$\/, use: 'css-loader' }     ]   } } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a SVG, \u0442\u0430\u043a \u0438 CSS-\u0444\u0430\u0439\u043b\u044b. \u041e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448\u0438 \u0441\u0442\u0438\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043b\u043e\u0430\u0434\u0435\u0440. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f <code>css-loader<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c CSS-\u0444\u0430\u0439\u043b\u044b. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0432 DOM. \u041c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b, \u043d\u043e \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0438\u0445 \u0432 \u0442\u0435\u0433 <code>&lt;style&gt;<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c DOM. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u0435\u043d <code>style-loader<\/code>. <\/p>\n<pre><code class=\"javascript\">npm i style-loader -D  <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"javascript\">module.exports = {   entry: '.\/app\/index.js',   module: {     rules: [       { test: \/\\.svg$\/, use: 'svg-inline-loader' },       { test: \/\\.css$\/, use: [ 'style-loader', 'css-loader' ] }     ]   } } <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 CSS-\u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u043b\u043e\u0430\u0434\u0435\u0440\u0430, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>use<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432. \u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u043e\u0430\u0434\u0435\u0440\u043e\u0432, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 <code>style-loader<\/code>, \u0437\u0430\u0442\u0435\u043c <code>css-loader<\/code>. \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e. \u0412\u0435\u0431\u043f\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u0445 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>css-loader<\/code> \u0434\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0430 <code>'.\/styles.css'<\/code>, \u0437\u0430\u0442\u0435\u043c <code>style-loader<\/code> \u0434\u043b\u044f \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0441\u0442\u0438\u043b\u0435\u0439 \u0432 DOM. <\/p>\n<p>  \u041b\u043e\u0430\u0434\u0435\u0440\u044b \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u0444\u0430\u0439\u043b\u043e\u0432, \u043d\u043e \u0438 \u0434\u043b\u044f \u0438\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0421\u0430\u043c\u044b\u043c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 JavaScript \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043a\u043e\u043b\u0435\u043d\u0438\u044f \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 JavaScript \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Babel. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>babel-loader<\/code>. <\/p>\n<pre><code class=\"javascript\">npm i babel-loader -D  <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"javascript\">module.exports = {   entry: '.\/app\/index.js',   module: {     rules: [       { test: \/\\.svg$\/, use: 'svg-inline-loader' },       { test: \/\\.css$\/, use: [ 'style-loader', 'css-loader' ] },       { test: \/\\.(js)$\/, use: 'babel-loader' }     ]   } } <\/code><\/pre>\n<p>  \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043b\u043e\u0430\u0434\u0435\u0440\u044b \u043f\u043e\u0447\u0442\u0438 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0444\u0430\u0439\u043b\u043e\u0432. <\/p>\n<h3>\u0422\u043e\u0447\u043a\u0430 \u0432\u044b\u0445\u043e\u0434\u0430<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0435\u0431\u043f\u0430\u043a \u0437\u043d\u0430\u0435\u0442 \u043e \u0442\u043e\u0447\u043a\u0435 \u0432\u0445\u043e\u0434\u0430 \u0438 \u043b\u043e\u0430\u0434\u0435\u0440\u0430\u0445. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0434\u043b\u044f \u0431\u0430\u043d\u0434\u043b\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>output<\/code> \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u0435\u0431\u043f\u0430\u043a\u0430. <\/p>\n<pre><code class=\"javascript\">const path = require('path')  module.exports = {   entry: '.\/app\/index.js',   module: {     rules: [       { test: \/\\.svg$\/, use: 'svg-inline-loader' },       { test: \/\\.css$\/, use: [ 'style-loader', 'css-loader' ] },       { test: \/\\.(js)$\/, use: 'babel-loader' }     ]   },   output: {     path: path.resolve(__dirname, 'dist'),     filename: 'index_bundle.js'   } } <\/code><\/pre>\n<p>  \u0412\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a: <\/p>\n<ol>\n<li>\u0412\u0435\u0431\u043f\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0443\u044e\u0441\u044f \u0432 <code>.\/app\/index.js<\/code><\/li>\n<li>\u041e\u043d \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b <code>import \/ require<\/code> \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0433\u0440\u0430\u0444 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/li>\n<li>\u0412\u0435\u0431\u043f\u0430\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0431\u0430\u043d\u0434\u043b, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u044f \u043a\u043e\u0434 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043b\u043e\u0430\u0434\u0435\u0440\u043e\u0432<\/li>\n<li>\u041e\u043d \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0431\u0430\u043d\u0434\u043b \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 <code>dist\/index_bundle.js<\/code><\/li>\n<\/ol>\n<p>  <\/p>\n<h3>\u041f\u043b\u0430\u0433\u0438\u043d\u044b (plugins)<\/h3>\n<p>  \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0430\u0434\u0435\u0440\u044b \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u0435\u0440\u0435\u0434 \u0438\u043b\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0431\u0430\u043d\u0434\u043b\u0430. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043b\u043e\u0430\u0434\u0435\u0440\u043e\u0432, \u043f\u043b\u0430\u0433\u0438\u043d\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0431\u0430\u043d\u0434\u043b\u0430. \u042d\u0442\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0433\u0443\u0442 \u043a\u0430\u0441\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0441\u0430\u043c\u043e\u0433\u043e \u0431\u0430\u043d\u0434\u043b\u0430, \u0442\u0430\u043a \u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u043f\u043b\u0430\u0433\u0438\u043d\u0430\u0445 \u043a\u0430\u043a \u043e \u0431\u043e\u043b\u0435\u0435 \u043c\u043e\u0449\u043d\u044b\u0445, \u043c\u0435\u043d\u0435\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0445 \u043b\u043e\u0430\u0434\u0435\u0440\u0430\u0445. <\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440. <\/p>\n<h3>HtmlWebpackPlugin<\/h3>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0432\u0435\u0431\u043f\u0430\u043a\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0431\u0430\u043d\u0434\u043b\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0441\u043b\u0430\u0442\u044c\u0441\u044f \u0432 <code>index.html<\/code>. <\/p>\n<p>  <code>HtmlWebpackPlugin<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u0442 <code>index.html<\/code> \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0441 \u0431\u0430\u043d\u0434\u043b\u043e\u043c \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u043d\u0435\u0433\u043e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0431\u0430\u043d\u0434\u043b. <\/p>\n<p>  \u041c\u044b \u043d\u0430\u0437\u0432\u0430\u043b\u0438 \u0431\u0430\u043d\u0434\u043b <code>index_bundle.js<\/code> \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b\u0438 \u0435\u0433\u043e \u0432 <code>dist<\/code>. <code>HtmlWebpackPlugin<\/code> \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b <code>index.html<\/code> \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>dist<\/code> \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u0432 \u043d\u0435\u0433\u043e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0431\u0430\u043d\u0434\u043b \u2014 <code>&lt;script src='index_bundle.js'&gt;&lt;\/script&gt;<\/code>. \u0417\u0434\u043e\u0440\u043e\u0432\u043e, \u043f\u0440\u0430\u0432\u0434\u0430? \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>index.html<\/code> \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f <code>HtmlWebpackPlugin<\/code>, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0442\u043e\u0447\u043a\u0443 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u043b\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0431\u0430\u043d\u0434\u043b\u0430, <code>HtmlWebpackPlugin<\/code> \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <code>index.html<\/code>. <\/p>\n<p>  \u041a\u0430\u043a \u043d\u0430\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u043b\u0430\u0433\u0438\u043d? \u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c. <\/p>\n<pre><code class=\"javascript\">npm i html-webpack-plugin -D  <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u0435\u0431\u043f\u0430\u043a\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>plugins<\/code>. <\/p>\n<pre><code class=\"javascript\">const path = require('path')  module.exports = {   entry: '.\/app\/index.js',   module: {     rules: [       { test: \/\\.svg$\/, use: 'svg-inline-loader' },       { test: \/\\.css$\/, use: [ 'style-loader', 'css-loader' ] },       { test: \/\\.(js)$\/, use: 'babel-loader' }     ]   },   output: {     path: path.resolve(__dirname, 'dist'),     filename: 'index_bundle.js'   },   plugins: [] } <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>HtmlWebpackPlugin<\/code> \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 <code>plugins<\/code>. <\/p>\n<pre><code class=\"javascript\"> const path = require('path') const HtmlWebpackPlugin = require('html-webpack-plugin')  module.exports = {   entry: '.\/app\/index.js',   module: {     rules: [       { test: \/\\.svg$\/, use: 'svg-inline-loader' },       { test: \/\\.css$\/, use: [ 'style-loader', 'css-loader' ] },       { test: \/\\.(js)$\/, use: 'babel-loader' }     ]   },   output: {     path: path.resolve(__dirname, 'dist'),     filename: 'index_bundle.js'   },   plugins: [     new HtmlWebpackPlugin()   ] } <\/code><\/pre>\n<p>  <\/p>\n<h3>EnvironmentPlugin<\/h3>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 React, \u0442\u043e \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <code>process.env.NODE_ENV<\/code> \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>production<\/code> \u043f\u0435\u0440\u0435\u0434 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435\u043c (\u0434\u0435\u043f\u043b\u043e\u0435\u043c) \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 React \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0443 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d\u0430, \u0443\u0434\u0430\u043b\u0438\u0432 \u0438\u043d\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f. \u0412\u0435\u0431\u043f\u0430\u043a \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043f\u043b\u0430\u0433\u0438\u043d\u0430 <code>EnvironmentPlugin<\/code>. \u041e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u0432\u0435\u0431\u043f\u0430\u043a\u0430, \u0442\u0430\u043a \u0447\u0442\u043e \u0435\u0433\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c. <\/p>\n<pre><code class=\"javascript\">const path = require('path') const HtmlWebpackPlugin = require('html-webpack-plugin') const webpack = require('webpack')  module.exports = {   entry: '.\/app\/index.js',   module: {     rules: [       { test: \/\\.svg$\/, use: 'svg-inline-loader' },       { test: \/\\.css$\/, use: [ 'style-loader', 'css-loader' ] },       { test: \/\\.(js)$\/, use: 'babel-loader' }     ]   },   output: {     path: path.resolve(__dirname, 'dist'),     filename: 'index_bundle.js'   },   plugins: [     new HtmlWebpackPlugin(),     new webpack.EnvironmentPlugin({       'NODE_ENV': 'production'     })   ] } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0440\u0435\u0436\u0438\u043c \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>process.env.NODE_ENV<\/code>. <\/p>\n<p>  <code>HtmlWebpackPlugin<\/code> \u0438 <code>EnvironmentPlugin<\/code> \u2014 \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432 \u0432\u0435\u0431\u043f\u0430\u043a\u0430. <\/p>\n<h3>\u0420\u0435\u0436\u0438\u043c (mode)<\/h3>\n<p>  \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043a \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d\u0443, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u041c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043e\u0434\u043d\u043e \u0438\u0437 \u043d\u0438\u0445 \u2014 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 <code>process.env.NODE_ENV<\/code> \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>production<\/code>. \u0414\u0440\u0443\u0433\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u0438\u043d\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u0430\u043d\u0434\u043b\u0430. <\/p>\n<p>  \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u044b \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447\u0438, \u043d\u043e \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043b\u0435\u0433\u043a\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431. \u0412 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0432\u0435\u0431\u043f\u0430\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <code>mode<\/code> \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>development<\/code> \u0438\u043b\u0438 <code>production<\/code> \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0440\u0435\u0434\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. <\/p>\n<pre><code class=\"javascript\">const path = require('path') const HtmlWebpackPlugin = require('html-webpack-plugin')  module.exports = {   entry: '.\/app\/index.js',   module: {     rules: [       { test: \/\\.svg$\/, use: 'svg-inline-loader' },       { test: \/\\.css$\/, use: [ 'style-loader', 'css-loader' ] },       { test: \/\\.(js)$\/, use: 'babel-loader' }     ]   },   output: {     path: path.resolve(__dirname, 'dist'),     filename: 'index_bundle.js'   },   plugins: [     new HtmlWebpackPlugin()   ],   mode: 'production' } <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u044b \u0443\u0434\u0430\u043b\u0438\u043b\u0438 <code>EnvironmentPlugin<\/code>. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 <code>mode<\/code> \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>production<\/code> \u0432\u0435\u0431\u043f\u0430\u043a \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 <code>process.env.NODE_ENV<\/code> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>production<\/code>. \u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u0438\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0434 \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f. <\/p>\n<h3>\u0417\u0430\u043f\u0443\u0441\u043a \u0432\u0435\u0431\u043f\u0430\u043a\u0430<\/h3>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u0435\u0431\u043f\u0430\u043a \u0438 \u043a\u0430\u043a \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c. <\/p>\n<p>  \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0444\u0430\u0439\u043b <code>package.json<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c <code>script<\/code> \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 <code>webpack<\/code>. <\/p>\n<pre><code class=\"javascript\">&quot;scripts&quot;: {   &quot;build&quot;: &quot;webpack&quot; } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>npm run build<\/code> \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0432\u0435\u0431\u043f\u0430\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0431\u0430\u043d\u0434\u043b <code>index_bundle.js<\/code> \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442 \u0435\u0433\u043e \u0432 <code>dist<\/code>. <\/p>\n<h3>\u0420\u0435\u0436\u0438\u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d\u0430<\/h3>\n<p>  \u0412 \u0446\u0435\u043b\u043e\u043c, \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438 \u0441 \u0432\u0435\u0431\u043f\u0430\u043a\u043e\u043c. \u041d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u0436\u0438\u043c\u0430\u043c\u0438. <\/p>\n<p>  \u041f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d\u0430, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u0441\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0440\u0435\u0436\u0438\u043c\u043e\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0435\u0440\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435. <\/p>\n<p>  \u0414\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u0436\u0438\u043c\u0430\u043c\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0432\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0432 <code>package.json<\/code>. <\/p>\n<p>  <code>npm run build<\/code> \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d-\u0431\u0430\u043d\u0434\u043b. <\/p>\n<p>  <code>npm run start<\/code> \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432. <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 <code>mode<\/code> \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>production<\/code> \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u0432\u0435\u0431\u043f\u0430\u043a\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u044d\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u041c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u0440\u0435\u0434\u044b \u0438\u043c\u0435\u043b\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442 <code>build<\/code> \u0432 <code>package.json<\/code>. <\/p>\n<pre><code class=\"javascript\">&quot;scripts&quot;: {   &quot;build&quot;: &quot;NODE_ENV='production' webpack&quot;, } <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 Windows, \u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439: <code>&quot;SET NODE_ENV='production' &amp;&amp; webpack&quot;<\/code>. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u0432\u0435\u0431\u043f\u0430\u043a\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043c\u0435\u043d\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>mode<\/code> \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 <code>process.env.NODE_ENV<\/code>. <\/p>\n<pre><code class=\"javascript\">...    mode: process.env.NODE_ENV === 'production' ? 'production' : 'development' } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u0433\u043e\u0442\u043e\u0432\u043e\u0433\u043e \u0431\u0430\u043d\u0434\u043b\u0430 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c <code>npm run build<\/code> \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435. \u0412 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>dist<\/code> \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u044b <code>index.html<\/code> \u0438 <code>index_bunlde.js<\/code>. <\/p>\n<h3>\u0421\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/h3>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c. \u041c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432\u0435\u0431\u043f\u0430\u043a \u0438 \u0436\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438. \u0412\u043e\u0442 \u0433\u0434\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0430\u043a\u0435\u0442 <code>webpack-dev-server<\/code>. <\/p>\n<p>  \u041a\u0430\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u044d\u0442\u043e \u0432\u0435\u0431\u043f\u0430\u043a-\u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412\u043c\u0435\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0438\u0440\u0435\u043a\u043e\u0440\u0438\u0438 <code>dist<\/code>, \u043e\u043d \u0445\u0440\u0430\u043d\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043e\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0436\u0438\u0432\u0443\u044e \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438 \u043b\u044e\u0431\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 <code>webpack-dev-server<\/code> \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0435\u0440\u0435\u0442 \u0444\u0430\u0439\u043b\u044b \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440. <\/p>\n<p>  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0430\u043a\u0435\u0442.<\/p>\n<pre><code class=\"javascript\">npm i webpack-dev-server -D  <\/code><\/pre>\n<p>  \u0412\u0441\u0435, \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 <code>start<\/code> \u0432 <code>package.json<\/code>. <\/p>\n<pre><code class=\"javascript\">&quot;scripts&quot;: {   &quot;build&quot;: &quot;NODE_ENV='production' webpack&quot;,   &quot;start&quot;: &quot;webpack-dev-server&quot; } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0434\u0432\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b: \u043e\u0434\u043d\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0434\u0440\u0443\u0433\u0430\u044f \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u0433\u043e\u0442\u043e\u0432\u043e\u0433\u043e \u0431\u0430\u043d\u0434\u043b\u0430. <\/p>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u044b\u043b\u0430 \u0432\u0430\u043c \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/514838\/\"> https:\/\/habr.com\/ru\/post\/514838\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/514838\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/k-\/tm\/2g\/k-tm2gvbb_ky6gdrd-tzqrzjkf4.png\"><\/p>\n<p>  \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0434\u0440\u0443\u0437\u044c\u044f! <\/p>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/ui.dev\/webpack\/\" rel=\"nofollow\">\u00abWebpack: A gentle introduction\u00bb<\/a> \u0430\u0432\u0442\u043e\u0440\u0430 Tyler McGinnis. <\/p>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0437\u0430\u0434\u0430\u0439\u0442\u0435 \u0441\u0435\u0431\u0435 \u0434\u0432\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u0430:<\/p>\n<ol>\n<li>\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d \u044d\u0442\u043e\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442?<\/li>\n<li>\u041a\u0430\u043a\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442?<\/li>\n<\/ol>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0438\u0437\u0443\u0447\u0430\u0435\u043c\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a Webpack.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-308353","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/308353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=308353"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/308353\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=308353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=308353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=308353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}