{"id":289581,"date":"2018-09-19T00:40:14","date_gmt":"2018-09-18T20:40:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=289581"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=289581","title":{"rendered":"\u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Webpack 4 \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<h1 id=\"predystoriya\">\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/h1>\n<p>  <\/p>\n<p>\u041d\u0438 \u0434\u043b\u044f \u043a\u043e\u0433\u043e \u043d\u0435 \u0441\u0435\u043a\u0440\u0435\u0442, \u0447\u0442\u043e \u0441 \u0432\u044b\u0445\u043e\u0434\u043e\u043c Webpack 4 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0430\u0441\u044c. \u0422\u0443\u0442 \u0434\u0430\u0436\u0435 \u043b\u0443\u0447\u0448\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u0437\u0430\u043d\u043e\u0432\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d\u0430, \u0442.\u043a. \u0441\u0442\u0430\u0440\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0430 \u043d\u043e\u0432\u044b\u0439 \u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0432 \u043a\u0443\u0440\u0441\u0435, \u043f\u043b\u0430\u0433\u0438\u043d\u0430 webpack.optimize.CommonsChunkPlugin \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442. \u0421\u043e\u0432\u0441\u0435\u043c. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u043f\u0438\u0441\u0430\u0442\u044c <a href=\"https:\/\/webpack.js.org\/guides\/code-splitting\/#prevent-duplication\">\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435<\/a>:<\/p>\n<p>  <\/p>\n<pre><code>module.exports = {   \/\/ ...   optimization: {     splitChunks: {       chunks: \"all\"     }   }   \/\/ ... }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u0430\u0433\u0438\u044f. \u0422.\u0435. \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c webpack&#8217;\u0443 \u0447\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0449\u0438\u043c \u0447\u0430\u043d\u043a\u043e\u043c, \u0430 \u043e\u043d \u0441\u0430\u043c \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u0442, \u0434\u0430 \u0435\u0449\u0435 \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0436\u0435 \u0438 \u043b\u0443\u0447\u0448\u0435 \u043d\u0430\u0441. <\/p>\n<p>  <\/p>\n<p>\u0418 \u043d\u0430\u0441\u0442\u0443\u043f\u0438\u0442 \u0441\u0447\u0430\u0441\u0442\u044c\u0435. \u0428\u0443\u0442\u043a\u0430. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0435\u0442&#8230;<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h1 id=\"bazovye-prigotovleniya\">\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f<\/h1>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code>module.exports = {   mode: 'development',   entry: {     index: '.\/src\/index.js',     another: '.\/src\/another-module.js'   },   output: {     filename: '[name].bundle.js',     path: path.resolve(__dirname, 'dist')   },   optimization: {     splitChunks: {       chunks: 'all'     }   } };<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0441\u0431\u043e\u0440\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 3 \u0444\u0430\u0439\u043b\u0430: another.bundle.js, index.bundle.js, vendors~another~index.bundle.js<\/p>\n<p>  <\/p>\n<pre><code>Hash: ac2ac6042ebb4f20ee54 Version: webpack 4.7.0 Time: 316ms                           Asset      Size                 Chunks             Chunk Names               another.bundle.js  5.95 KiB                another  [emitted]  another                 index.bundle.js  5.89 KiB                  index  [emitted]  index vendors~another~index.bundle.js   547 KiB  vendors~another~index  [emitted]  vendors~another~index Entrypoint index = vendors~another~index.bundle.js index.bundle.js Entrypoint another = vendors~another~index.bundle.js another.bundle.js [.\/node_modules\/webpack\/buildin\/global.js] (webpack)\/buildin\/global.js 489 bytes {vendors~another~index} [built] [.\/node_modules\/webpack\/buildin\/module.js] (webpack)\/buildin\/module.js 497 bytes {vendors~another~index} [built] [.\/src\/another-module.js] 88 bytes {another} [built] [.\/src\/index.js] 86 bytes {index} [built]     + 1 hidden module<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u0432\u0435\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043c\u044b, \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c vendors~another~index.bundle.js \u0438 index.bundle.js, \u0430 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c vendors~another~index.bundle.js \u0438 another.bundle.js.<\/p>\n<p>  <\/p>\n<h1 id=\"v-chem-problema\">\u0412 \u0447\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430?<\/h1>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0438\u043c\u0435\u043d\u0438 <strong>vendors~another~index<\/strong>.bundle.js. \u041f\u043e\u043a\u0430 \u0443 \u043d\u0430\u0441 \u043c\u0435\u043d\u044c\u0448\u0435 \u0442\u0440\u0435\u0445 \u0442\u043e\u0447\u0435\u043a \u0432\u0445\u043e\u0434\u0430, \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. \u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u2014 \u0431\u0430\u043d\u0434\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 npm \u043c\u043e\u0434\u0443\u043b\u0438 (\u043e\u043d\u0438 \u0436\u0435 vendors) \u0438 \u043e\u0431\u0449\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0434\u043b\u044f index \u0438 another. \u041d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0438\u0437 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043c\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c 2 \u0444\u0430\u0439\u043b\u0430 \u0438 \u043d\u0435 \u0438\u043c\u0435\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c.<\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0442\u0440\u0438 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430, \u0442\u043e \u043d\u043e\u0432\u044b\u0445 \u0431\u0430\u043d\u0434\u043b\u043e\u0432 (\u043e\u043d\u0438 \u0436\u0435 \u0447\u0430\u043d\u043a\u0438) \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438 \u043c\u044b \u0443\u0436\u0435 \u043d\u0435 \u0437\u043d\u0430\u0435\u043c \u043d\u0438 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430, \u043d\u0438 \u0438\u043c\u0435\u043d. \u0412\u0441\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0435\u0449\u0435 \u0432\u0435\u0441\u0435\u043b\u0435\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u0435\u0449\u0435 \u0438 css \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u0418 \u044d\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430.<\/p>\n<p>  <\/p>\n<h1 id=\"kak-reshit-etu-problemu\">\u041a\u0430\u043a \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443?<\/h1>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b webpack \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b\u0438 \u0431\u044b \u0432 \u0441\u0435\u0431\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u0431\u0430\u043d\u0434\u043b\u044b \u043d\u0430 \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043d\u0430\u0434\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c. \u0418 \u0432 \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0432 output&#8217;\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code>Entrypoint index = vendors~another~index.bundle.js index.bundle.js Entrypoint another = vendors~another~index.bundle.js another.bundle.js<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0430\u0434\u043e. \u0422.\u0435. webpack \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0437\u043d\u0430\u0435\u0442 \u043a\u0430\u043a\u0438\u0435 \u0431\u0430\u043d\u0434\u043b\u044b \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430, \u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u0441\u0430\u043c \u043d\u0435 \u0445\u043e\u0447\u0435\u0442 \u044d\u0442\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u0441 \u043d\u0430\u043c\u0438 \u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u041c\u0430\u043d\u0438\u0444\u0435\u0441\u0442 \u043d\u0430\u043c \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442. \u0414\u0430, \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 (vendors~another~index.bundle.js) \u0431\u0430\u043d\u0434\u043b \u0435\u0441\u0442\u044c. \u041c\u044b \u0437\u043d\u0430\u0435\u043c \u0433\u0434\u0435 \u043e\u043d \u043b\u0435\u0436\u0438\u0442. \u041d\u043e \u043a\u043e\u043c\u0443 \u043e\u043d \u043d\u0443\u0436\u0435\u043d \u043d\u0435 \u0437\u043d\u0430\u0435\u043c. \u0422.\u0435. \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442 \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u0435\u043d.<\/p>\n<p>  <\/p>\n<p>\u0422\u043e\u0433\u0434\u0430 \u044f \u0440\u0435\u0448\u0438\u043b \u0447\u0442\u043e \u0440\u0430\u0437 webpack \u0437\u043d\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0442\u043e \u0435\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432. \u0413\u043e\u0442\u043e\u0432\u044b\u0445 \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b \u0438 \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439. \u0418, \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0434\u0438 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u043b\u0430\u0433\u0438\u043d\u0430, \u044f \u0438 \u043f\u0438\u0448\u0443 \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e.<\/p>\n<p>  <\/p>\n<pre><code>import * as webpack from \"webpack\";  export interface IChunkDescription {     readonly id: string | number;     readonly name: string;     readonly files: string[]; }  export interface IEntrypointsPluginOptions {     readonly filename: string;     readonly replacer?: (key: string, value: any) =&gt; any;     readonly space?: string | number;     readonly filter?: (chunk: IChunkDescription) =&gt; boolean; }  export default class EntrypointsPlugin {     private readonly options: IEntrypointsPluginOptions;      public constructor(options: IEntrypointsPluginOptions) {         this.options = Object.assign&lt;IEntrypointsPluginOptions, IEntrypointsPluginOptions&gt;({             filename: \"entrypoints.json\",             replacer: null,             space: null,             filter: null         }, options);     }      public apply(compiler: webpack.Compiler): void {         compiler.hooks.emit.tap(\"entrypoints\", (compilation: webpack.compilation.Compilation) =&gt; {             let data = {};             let entrypoints = {};              const filter = this.options.filter;             const publicPath = compilation.compiler.options.output.publicPath;              for (let [key, value] of compilation.entrypoints.entries()) {                 const chunks: IChunkDescription[] = value.chunks.map(data =&gt; {                     const chunk: IChunkDescription = {                         id: data.id,                         name: data.name,                         files: data.files                     };                     return filter == null || filter(chunk) ? chunk : null;                 });                  const files = ([] as string[]).concat(...chunks.filter(c =&gt; c != null)                   .map(c =&gt; c.files.map(f =&gt; publicPath + f)));                 const js = files.filter(f =&gt; \/.js\/.test(f) &amp;&amp; !\/.js.map\/.test(f));                 const css = files.filter(f =&gt; \/.css\/.test(f) &amp;&amp; !\/.css.map\/.test(f));                  let entrypoint = {};                 if (js.length) entrypoint[\"js\"] = js;                 if (css.length) entrypoint[\"css\"] = css;                  data[key] = entrypoint;             }             const json = JSON.stringify(data, this.options.replacer, this.options.space);             compilation.assets[this.options.filename] = {                 source: () =&gt; json,                 size: () =&gt; json.length             };         });     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 webpack.config.(ts|js) \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u043b\u0430\u0433\u0438\u043d:<\/p>\n<p>  <\/p>\n<pre><code>plugins: [   new EntrypointsPlugin({     filename: \"entrypoints.json\",     space: 2   }) ]<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438 \u0434\u043e\u0436\u0434\u0435\u043c\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0444\u0430\u0439\u043b entrypoints.json \u0441 \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c:<\/p>\n<p>  <\/p>\n<pre><code>{   \"index\": {     \"js\": [\"vendors~another~index.bundle.js\", \"index.bundle.js\"]   },   \"another\": {     \"js\": [\"vendors~another~index.bundle.js\", \"another.bundle.js\"]   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f extract-css, \u0442\u043e \u043a\u0440\u043e\u043c\u0435 \u0441\u0435\u043a\u0446\u0438\u0438 js \u0431\u0443\u0434\u0435\u0442 \u0435\u0449\u0435 \u0438 css.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f, \u043f\u0440\u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 HTML \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u044d\u0442\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0444\u0430\u0439\u043b entrypoints.json, \u043d\u0430\u0439\u0442\u0438 \u043d\u0443\u0436\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c js \u0438 css \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432.<\/p>\n<p>  <\/p>\n<h1 id=\"problema-reshena\">\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0435\u043d\u0430<\/h1>\n<p>  <\/p>\n<p>\u041a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a.<\/p>\n<\/div>\n<p>        <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \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\/post\/423693\/\"> https:\/\/habr.com\/post\/423693\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<h1 id=\"predystoriya\">\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/h1>\n<p>  <\/p>\n<p>\u041d\u0438 \u0434\u043b\u044f \u043a\u043e\u0433\u043e \u043d\u0435 \u0441\u0435\u043a\u0440\u0435\u0442, \u0447\u0442\u043e \u0441 \u0432\u044b\u0445\u043e\u0434\u043e\u043c Webpack 4 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0430\u0441\u044c. \u0422\u0443\u0442 \u0434\u0430\u0436\u0435 \u043b\u0443\u0447\u0448\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u0437\u0430\u043d\u043e\u0432\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d\u0430, \u0442.\u043a. \u0441\u0442\u0430\u0440\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0430 \u043d\u043e\u0432\u044b\u0439 \u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0432 \u043a\u0443\u0440\u0441\u0435, \u043f\u043b\u0430\u0433\u0438\u043d\u0430 webpack.optimize.CommonsChunkPlugin \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442. \u0421\u043e\u0432\u0441\u0435\u043c. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u043f\u0438\u0441\u0430\u0442\u044c <a href=\"https:\/\/webpack.js.org\/guides\/code-splitting\/#prevent-duplication\">\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435<\/a>:<\/p>\n<p>  <\/p>\n<pre><code>module.exports = {   \/\/ ...   optimization: {     splitChunks: {       chunks: \"all\"     }   }   \/\/ ... }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u0430\u0433\u0438\u044f. \u0422.\u0435. \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c webpack&#8217;\u0443 \u0447\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0449\u0438\u043c \u0447\u0430\u043d\u043a\u043e\u043c, \u0430 \u043e\u043d \u0441\u0430\u043c \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u0442, \u0434\u0430 \u0435\u0449\u0435 \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0436\u0435 \u0438 \u043b\u0443\u0447\u0448\u0435 \u043d\u0430\u0441. <\/p>\n<p>  <\/p>\n<p>\u0418 \u043d\u0430\u0441\u0442\u0443\u043f\u0438\u0442 \u0441\u0447\u0430\u0441\u0442\u044c\u0435. \u0428\u0443\u0442\u043a\u0430. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0435\u0442&#8230;<\/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-289581","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/289581","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=289581"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/289581\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=289581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=289581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=289581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}