From b204df8b894538d01690fb347d24650b44336db9 Mon Sep 17 00:00:00 2001 From: Court Ewing Date: Sun, 7 Jan 2018 08:21:39 -0500 Subject: [PATCH] Revert "[optimizer] More aggressive chunking of common/vendor code (#15816)" This reverts commit 92b373b3048f1be2b380781b76e4255f31e6a6a1. --- src/optimize/base_optimizer.js | 24 +++++++++--------------- src/ui/ui_render/views/ui_app.jade | 3 --- tasks/config/karma.js | 6 ------ 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/optimize/base_optimizer.js b/src/optimize/base_optimizer.js index 27d2a17ec79eb6..5b4d1493725111 100644 --- a/src/optimize/base_optimizer.js +++ b/src/optimize/base_optimizer.js @@ -3,6 +3,10 @@ import { writeFile } from 'fs'; import Boom from 'boom'; import ExtractTextPlugin from 'extract-text-webpack-plugin'; import webpack from 'webpack'; +import CommonsChunkPlugin from 'webpack/lib/optimize/CommonsChunkPlugin'; +import DefinePlugin from 'webpack/lib/DefinePlugin'; +import UglifyJsPlugin from 'webpack/lib/optimize/UglifyJsPlugin'; +import NoEmitOnErrorsPlugin from 'webpack/lib/NoEmitOnErrorsPlugin'; import Stats from 'webpack/lib/Stats'; import webpackMerge from 'webpack-merge'; @@ -94,8 +98,6 @@ export default class BaseOptimizer { }); } - const nodeModulesPath = fromRoot('node_modules'); - /** * Adds a cache loader if we're running in dev mode. The reason we're not adding * the cache-loader when running in production mode is that it creates cache @@ -139,20 +141,12 @@ export default class BaseOptimizer { allChunks: true }), - new webpack.optimize.CommonsChunkPlugin({ + new CommonsChunkPlugin({ name: 'commons', - filename: 'commons.bundle.js', - minChunks: 2, - }), - - new webpack.optimize.CommonsChunkPlugin({ - name: 'vendors', - filename: 'vendors.bundle.js', - // only combine node_modules from Kibana - minChunks: module => module.context && module.context.indexOf(nodeModulesPath) !== -1 + filename: 'commons.bundle.js' }), - new webpack.NoEmitOnErrorsPlugin(), + new NoEmitOnErrorsPlugin(), ], module: { @@ -239,12 +233,12 @@ export default class BaseOptimizer { return webpackMerge(commonConfig, { plugins: [ - new webpack.DefinePlugin({ + new DefinePlugin({ 'process.env': { 'NODE_ENV': '"production"' } }), - new webpack.optimize.UglifyJsPlugin({ + new UglifyJsPlugin({ compress: { warnings: false }, diff --git a/src/ui/ui_render/views/ui_app.jade b/src/ui/ui_render/views/ui_app.jade index 120f26ad9046af..1595059410bfa0 100644 --- a/src/ui/ui_render/views/ui_app.jade +++ b/src/ui/ui_render/views/ui_app.jade @@ -120,11 +120,8 @@ block content return anchor.href; } var files = [ - bundleFile('vendors.style.css'), bundleFile('commons.style.css'), bundleFile('#{app.getId()}.style.css'), - - bundleFile('vendors.bundle.js'), bundleFile('commons.bundle.js'), bundleFile('#{app.getId()}.bundle.js') ]; diff --git a/tasks/config/karma.js b/tasks/config/karma.js index b72df5f6ad7097..b362b5471c6e57 100644 --- a/tasks/config/karma.js +++ b/tasks/config/karma.js @@ -37,11 +37,8 @@ module.exports = function (grunt) { // list of files / patterns to load in the browser files: [ - 'http://localhost:5610/bundles/vendors.bundle.js', 'http://localhost:5610/bundles/commons.bundle.js', 'http://localhost:5610/bundles/tests.bundle.js', - - 'http://localhost:5610/bundles/vendors.style.css', 'http://localhost:5610/bundles/commons.style.css', 'http://localhost:5610/bundles/tests.style.css' ], @@ -129,11 +126,8 @@ module.exports = function (grunt) { singleRun: true, options: { files: [ - 'http://localhost:5610/bundles/vendors.bundle.js', 'http://localhost:5610/bundles/commons.bundle.js', `http://localhost:5610/bundles/tests.bundle.js?shards=${TOTAL_CI_SHARDS}&shard_num=${n}`, - - 'http://localhost:5610/bundles/vendors.style.css', 'http://localhost:5610/bundles/commons.style.css', 'http://localhost:5610/bundles/tests.style.css' ]