diff --git a/config/helpers/is_jh_env.js b/config/helpers/is_jh_env.js new file mode 100644 index 0000000000000000000000000000000000000000..5afeee2f498a8ba399c4db6567bf88d81e8c769e --- /dev/null +++ b/config/helpers/is_jh_env.js @@ -0,0 +1,15 @@ +const fs = require('fs'); +const path = require('path'); +const IS_EE = require('./is_ee_env'); + +const ROOT_PATH = path.resolve(__dirname, '../..'); + +// The `FOSS_ONLY` is always `string` or `nil` +// Thus the nil or empty string will result +// in using default value: false +// +// The behavior needs to be synchronised with +// lib/gitlab.rb: Gitlab.jh? +// Since IS_EE already satisifies the conditions of not being a FOSS_ONLY. +// const isFossOnly = JSON.parse(process.env.FOSS_ONLY || 'false'); +module.exports = IS_EE && fs.existsSync(path.join(ROOT_PATH, 'jh')); diff --git a/config/webpack.config.js b/config/webpack.config.js index 146df2c613b199d2f63a2b9922f00c5a670c80e9..b81b56110418f3fb2984507b7d7cbbf6e014f337 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -20,6 +20,7 @@ const WEBPACK_VERSION = require('webpack/package.json').version; const createIncrementalWebpackCompiler = require('./helpers/incremental_webpack_compiler'); const IS_EE = require('./helpers/is_ee_env'); +const IS_JH = require('./helpers/is_jh_env'); const vendorDllHash = require('./helpers/vendor_dll_hash'); const MonacoWebpackPlugin = require('./plugins/monaco_webpack'); @@ -97,6 +98,14 @@ function generateEntries() { watchAutoEntries.push(path.join(ROOT_PATH, 'ee/app/assets/javascripts/pages/')); } + if (IS_JH) { + const eePageEntries = glob.sync('pages/**/index.js', { + cwd: path.join(ROOT_PATH, 'jh/app/assets/javascripts'), + }); + eePageEntries.forEach((entryPath) => generateAutoEntries(entryPath, 'jh')); + watchAutoEntries.push(path.join(ROOT_PATH, 'jh/app/assets/javascripts/pages/')); + } + const autoEntryKeys = Object.keys(autoEntriesMap); autoEntriesCount = autoEntryKeys.length; @@ -168,6 +177,16 @@ if (IS_EE) { }); } +if (IS_JH) { + Object.assign(alias, { + jh: path.join(ROOT_PATH, 'jh/app/assets/javascripts'), + jh_icons: path.join(ROOT_PATH, 'jh/app/views/shared/icons'), + jh_images: path.join(ROOT_PATH, 'jh/app/assets/images'), + jh_spec: path.join(ROOT_PATH, 'jh/spec/javascripts'), + jh_jest: path.join(ROOT_PATH, 'jh/spec/frontend'), + }); +} + if (!IS_PRODUCTION) { const fixtureDir = IS_EE ? 'fixtures-ee' : 'fixtures';