From 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 19 Sep 2022 23:18:09 +0000 Subject: Add latest changes from gitlab-org/gitlab@15-4-stable-ee --- config/webpack.config.js | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'config/webpack.config.js') diff --git a/config/webpack.config.js b/config/webpack.config.js index 0d759de4900..146e9b48442 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -6,6 +6,7 @@ const path = require('path'); const BABEL_VERSION = require('@babel/core/package.json').version; const SOURCEGRAPH_VERSION = require('@sourcegraph/code-host-integration/package.json').version; +const GITLAB_WEB_IDE_VERSION = require('@gitlab/web-ide/package.json').version; const BABEL_LOADER_VERSION = require('babel-loader/package.json').version; const CompressionPlugin = require('compression-webpack-plugin'); @@ -54,17 +55,31 @@ const INCREMENTAL_COMPILER_RECORD_HISTORY = IS_DEV_SERVER && !process.env.CI; const WEBPACK_REPORT = process.env.WEBPACK_REPORT && process.env.WEBPACK_REPORT !== 'false'; const WEBPACK_MEMORY_TEST = process.env.WEBPACK_MEMORY_TEST && process.env.WEBPACK_MEMORY_TEST !== 'false'; -const NO_COMPRESSION = process.env.NO_COMPRESSION && process.env.NO_COMPRESSION !== 'false'; -const NO_SOURCEMAPS = process.env.NO_SOURCEMAPS && process.env.NO_SOURCEMAPS !== 'false'; +let NO_COMPRESSION = process.env.NO_COMPRESSION && process.env.NO_COMPRESSION !== 'false'; +let NO_SOURCEMAPS = process.env.NO_SOURCEMAPS && process.env.NO_SOURCEMAPS !== 'false'; +let NO_HASHED_CHUNKS = process.env.NO_HASHED_CHUNKS && process.env.NO_HASHED_CHUNKS !== 'false'; + +if (WEBPACK_REPORT) { + console.log('Webpack report enabled. Running a "slim" production build.'); + // For our webpack report we need no source maps, compression _or_ hashed file names. + NO_SOURCEMAPS = true; + NO_COMPRESSION = true; + NO_HASHED_CHUNKS = true; +} const WEBPACK_OUTPUT_PATH = path.join(ROOT_PATH, 'public/assets/webpack'); const WEBPACK_PUBLIC_PATH = '/assets/webpack/'; const SOURCEGRAPH_PACKAGE = '@sourcegraph/code-host-integration'; +const GITLAB_WEB_IDE_PACKAGE = '@gitlab/web-ide'; const SOURCEGRAPH_PATH = path.join('sourcegraph', SOURCEGRAPH_VERSION, '/'); const SOURCEGRAPH_OUTPUT_PATH = path.join(WEBPACK_OUTPUT_PATH, SOURCEGRAPH_PATH); const SOURCEGRAPH_PUBLIC_PATH = path.join(WEBPACK_PUBLIC_PATH, SOURCEGRAPH_PATH); +const GITLAB_WEB_IDE_PATH = path.join('gitlab-vscode', GITLAB_WEB_IDE_VERSION, '/'); +const GITLAB_WEB_IDE_OUTPUT_PATH = path.join(WEBPACK_OUTPUT_PATH, GITLAB_WEB_IDE_PATH); +const GITLAB_WEB_IDE_PUBLIC_PATH = path.join(WEBPACK_PUBLIC_PATH, GITLAB_WEB_IDE_PATH); + const devtool = IS_PRODUCTION ? 'source-map' : 'cheap-module-eval-source-map'; let autoEntriesCount = 0; @@ -245,8 +260,10 @@ module.exports = { output: { path: WEBPACK_OUTPUT_PATH, publicPath: WEBPACK_PUBLIC_PATH, - filename: IS_PRODUCTION ? '[name].[contenthash:8].bundle.js' : '[name].bundle.js', - chunkFilename: IS_PRODUCTION ? '[name].[contenthash:8].chunk.js' : '[name].chunk.js', + filename: + IS_PRODUCTION && !NO_HASHED_CHUNKS ? '[name].[contenthash:8].bundle.js' : '[name].bundle.js', + chunkFilename: + IS_PRODUCTION && !NO_HASHED_CHUNKS ? '[name].[contenthash:8].chunk.js' : '[name].chunk.js', globalObject: 'this', // allow HMR and web workers to play nice }, @@ -473,7 +490,9 @@ module.exports = { new VueLoaderPlugin(), // automatically configure monaco editor web workers - new MonacoWebpackPlugin(), + new MonacoWebpackPlugin({ + filename: '[name].[contenthash:8].worker.js', + }), new GraphqlKnownOperationsPlugin({ filename: 'graphql_known_operations.yml' }), @@ -582,6 +601,10 @@ module.exports = { ignore: ['package.json'], }, }, + { + from: path.join(ROOT_PATH, 'node_modules', GITLAB_WEB_IDE_PACKAGE, 'dist', 'public'), + to: GITLAB_WEB_IDE_OUTPUT_PATH, + }, { from: path.join( ROOT_PATH, @@ -677,6 +700,8 @@ module.exports = { statsFilename: path.join(ROOT_PATH, 'webpack-report/stats.json'), statsOptions: { source: false, + errors: false, + warnings: false, }, }), @@ -689,6 +714,7 @@ module.exports = { IS_JH: IS_JH ? 'window.gon && window.gon.jh' : JSON.stringify(false), // This is used by Sourcegraph because these assets are loaded dnamically 'process.env.SOURCEGRAPH_PUBLIC_PATH': JSON.stringify(SOURCEGRAPH_PUBLIC_PATH), + 'process.env.GITLAB_WEB_IDE_PUBLIC_PATH': JSON.stringify(GITLAB_WEB_IDE_PUBLIC_PATH), ...(IS_PRODUCTION ? {} : { LIVE_RELOAD: DEV_SERVER_LIVERELOAD }), }), -- cgit v1.2.1