Support prod bundles generation on dll from env (#27259) (#27409)

* chore(NA): fix-env-prod-for-dll.

* refact(NA): changed the condition to generate dll accordingly an env.
This commit is contained in:
Tiago Costa 2018-12-18 17:59:38 +00:00 committed by GitHub
parent d8c3723505
commit d2e0b26f68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 13 deletions

View file

@ -32,10 +32,9 @@ const existsAsync = promisify(fs.exists);
const writeFileAsync = promisify(fs.writeFile);
export class DllCompiler {
static getRawDllConfig(alias = {}, noParseRules = []) {
static getRawDllConfig(uiBundles = {}) {
return {
alias,
noParseRules,
uiBundles,
context: fromRoot('.'),
entryName: 'vendors',
dllName: '[name]',
@ -52,8 +51,7 @@ export class DllCompiler {
constructor(uiBundles, log) {
this.rawDllConfig = DllCompiler.getRawDllConfig(
uiBundles.getAliases(),
uiBundles.getWebpackNoParseRules()
uiBundles
);
this.log = log || (() => null);
}

View file

@ -17,7 +17,7 @@
* under the License.
*/
import { fromRoot, IS_KIBANA_DISTRIBUTABLE } from '../../utils';
import { fromRoot } from '../../utils';
import webpack from 'webpack';
import webpackMerge from 'webpack-merge';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
@ -131,8 +131,9 @@ function generateDLL(config) {
function extendRawConfig(rawConfig) {
// Build all extended configs from raw config
const dllAlias = rawConfig.alias;
const dllNoParseRules = rawConfig.noParseRules;
const dllAlias = rawConfig.uiBundles.getAliases();
const dllNoParseRules = rawConfig.uiBundles.getWebpackNoParseRules();
const dllDevMode = rawConfig.uiBundles.isDevMode();
const dllContext = rawConfig.context;
const dllEntry = {};
const dllEntryName = rawConfig.entryName;
@ -158,6 +159,7 @@ function extendRawConfig(rawConfig) {
return {
dllAlias,
dllNoParseRules,
dllDevMode,
dllContext,
dllEntry,
dllOutputPath,
@ -169,9 +171,9 @@ function extendRawConfig(rawConfig) {
};
}
function common(rawConfig) {
function common(config) {
return webpackMerge(
generateDLL(extendRawConfig(rawConfig))
generateDLL(config)
);
}
@ -234,9 +236,11 @@ function unoptimized() {
}
export function configModel(rawConfig = {}) {
if (IS_KIBANA_DISTRIBUTABLE) {
return webpackMerge(common(rawConfig), optimized());
const config = extendRawConfig(rawConfig);
if (config.dllDevMode) {
return webpackMerge(common(config), unoptimized());
}
return webpackMerge(common(rawConfig), unoptimized());
return webpackMerge(common(config), optimized());
}