mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
There are several cases where we want to do different things in the optimizer based on whether we are running in the distributable version of Kibana or running from source. Historically we have handled this by relying on the env, but as we start to prebuild things, like TypeScript and soon SCSS, we actually need to know if the version of Kibana running was a result of the build process or not. To address this the src/utils module now exports a constant: `IS_KIBANA_DISTRIBUTABLE`. This constant will be based on the build.distributable flag being set in Kibana's package.json, which is done automatically in the build process.
This commit is contained in:
parent
e8cc31a9c0
commit
63fd1f5ae6
6 changed files with 30 additions and 10 deletions
|
@ -36,6 +36,7 @@ export const CreatePackageJsonTask = {
|
|||
build: {
|
||||
number: config.getBuildNumber(),
|
||||
sha: config.getBuildSha(),
|
||||
distributable: true,
|
||||
},
|
||||
repository: pkg.repository,
|
||||
engines: {
|
||||
|
|
|
@ -27,7 +27,7 @@ import webpackMerge from 'webpack-merge';
|
|||
|
||||
import { defaults } from 'lodash';
|
||||
|
||||
import { fromRoot } from '../utils';
|
||||
import { IS_KIBANA_DISTRIBUTABLE, fromRoot } from '../utils';
|
||||
|
||||
import { PUBLIC_PATH_PLACEHOLDER } from './public_path_placeholder';
|
||||
|
||||
|
@ -122,7 +122,7 @@ export default class BaseOptimizer {
|
|||
* of Kibana and just make compressing and extracting it more difficult.
|
||||
*/
|
||||
const maybeAddCacheLoader = (cacheName, loaders) => {
|
||||
if (!this.uiBundles.isDevMode()) {
|
||||
if (IS_KIBANA_DISTRIBUTABLE) {
|
||||
return loaders;
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ export default class BaseOptimizer {
|
|||
},
|
||||
};
|
||||
|
||||
if (this.uiBundles.isDevMode()) {
|
||||
if (!IS_KIBANA_DISTRIBUTABLE) {
|
||||
return webpackMerge(commonConfig, {
|
||||
module: {
|
||||
rules: [
|
||||
|
|
|
@ -21,7 +21,7 @@ import Joi from 'joi';
|
|||
import _ from 'lodash';
|
||||
import override from './override';
|
||||
import createDefaultSchema from './schema';
|
||||
import { pkg, unset, deepCloneWithBuffers as clone } from '../../utils';
|
||||
import { pkg, unset, deepCloneWithBuffers as clone, IS_KIBANA_DISTRIBUTABLE } from '../../utils';
|
||||
|
||||
const schema = Symbol('Joi Schema');
|
||||
const schemaExts = Symbol('Schema Extensions');
|
||||
|
@ -107,8 +107,8 @@ export class Config {
|
|||
notDev: !dev,
|
||||
version: _.get(pkg, 'version'),
|
||||
branch: _.get(pkg, 'branch'),
|
||||
buildNum: dev ? Math.pow(2, 53) - 1 : _.get(pkg, 'build.number', NaN),
|
||||
buildSha: dev ? 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' : _.get(pkg, 'build.sha', '')
|
||||
buildNum: IS_KIBANA_DISTRIBUTABLE ? pkg.build.number : Number.MAX_SAFE_INTEGER,
|
||||
buildSha: IS_KIBANA_DISTRIBUTABLE ? pkg.build.sha : 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
||||
};
|
||||
|
||||
if (!context.dev && !context.prod) {
|
||||
|
|
|
@ -128,10 +128,6 @@ export class UiBundlesController {
|
|||
return this._appExtensions;
|
||||
}
|
||||
|
||||
isDevMode() {
|
||||
return this._env === 'development';
|
||||
}
|
||||
|
||||
getContext() {
|
||||
return JSON.stringify(this._context, null, ' ');
|
||||
}
|
||||
|
|
22
src/utils/artifact_type.js
Normal file
22
src/utils/artifact_type.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { pkg } from './package_json';
|
||||
|
||||
export const IS_KIBANA_DISTRIBUTABLE = pkg.build && pkg.build.distributable === true;
|
|
@ -27,6 +27,7 @@ export { encodeQueryComponent } from './encode_query_component';
|
|||
export { modifyUrl } from './modify_url';
|
||||
export { getFlattenedObject } from './get_flattened_object';
|
||||
export { watchStdioForLine } from './watch_stdio_for_line';
|
||||
export { IS_KIBANA_DISTRIBUTABLE } from './artifact_type';
|
||||
|
||||
export {
|
||||
getKbnTypeNames,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue