Commit c3296aba authored by Paul Slaughter's avatar Paul Slaughter

Move sourcegraph assets to versioned subdirectory

Also consolidates some webpack config with
shared constants

Also @markrian helped word the CHANGELOG
parent 6e896a5f
...@@ -17,7 +17,7 @@ export default function initSourcegraph() { ...@@ -17,7 +17,7 @@ export default function initSourcegraph() {
return; return;
} }
const assetsUrl = new URL('/assets/webpack/sourcegraph/', window.location.href); const assetsUrl = new URL(process.env.SOURCEGRAPH_PUBLIC_PATH, window.location.href);
const scriptPath = new URL('scripts/integration.bundle.js', assetsUrl).href; const scriptPath = new URL('scripts/integration.bundle.js', assetsUrl).href;
window.SOURCEGRAPH_ASSETS_URL = assetsUrl.href; window.SOURCEGRAPH_ASSETS_URL = assetsUrl.href;
......
---
title: Make sure Sourcegraph asset always loads successfully
merge_request: 49030
author:
type: fixed
...@@ -29,9 +29,18 @@ const WEBPACK_MEMORY_TEST = ...@@ -29,9 +29,18 @@ const WEBPACK_MEMORY_TEST =
const NO_COMPRESSION = process.env.NO_COMPRESSION && process.env.NO_COMPRESSION !== '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'; const NO_SOURCEMAPS = process.env.NO_SOURCEMAPS && process.env.NO_SOURCEMAPS !== 'false';
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 VUE_VERSION = require('vue/package.json').version; const VUE_VERSION = require('vue/package.json').version;
const VUE_LOADER_VERSION = require('vue-loader/package.json').version; const VUE_LOADER_VERSION = require('vue-loader/package.json').version;
const WEBPACK_VERSION = require('webpack/package.json').version; const WEBPACK_VERSION = require('webpack/package.json').version;
const SOURCEGRAPH_VERSION = require(path.join(SOURCEGRAPH_PACKAGE, 'package.json')).version;
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 devtool = IS_PRODUCTION ? 'source-map' : 'cheap-module-eval-source-map'; const devtool = IS_PRODUCTION ? 'source-map' : 'cheap-module-eval-source-map';
...@@ -143,7 +152,7 @@ if (VENDOR_DLL && !IS_PRODUCTION) { ...@@ -143,7 +152,7 @@ if (VENDOR_DLL && !IS_PRODUCTION) {
dll = { dll = {
manifestPath: path.join(dllCachePath, 'vendor.dll.manifest.json'), manifestPath: path.join(dllCachePath, 'vendor.dll.manifest.json'),
cacheFrom: dllCachePath, cacheFrom: dllCachePath,
cacheTo: path.join(ROOT_PATH, `public/assets/webpack/dll.${dllHash}/`), cacheTo: path.join(WEBPACK_OUTPUT_PATH, `dll.${dllHash}/`),
publicPath: `dll.${dllHash}/vendor.dll.bundle.js`, publicPath: `dll.${dllHash}/vendor.dll.bundle.js`,
exists: null, exists: null,
}; };
...@@ -157,8 +166,8 @@ module.exports = { ...@@ -157,8 +166,8 @@ module.exports = {
entry: generateEntries, entry: generateEntries,
output: { output: {
path: path.join(ROOT_PATH, 'public/assets/webpack'), path: WEBPACK_OUTPUT_PATH,
publicPath: '/assets/webpack/', publicPath: WEBPACK_PUBLIC_PATH,
filename: IS_PRODUCTION ? '[name].[contenthash:8].bundle.js' : '[name].bundle.js', filename: IS_PRODUCTION ? '[name].[contenthash:8].bundle.js' : '[name].bundle.js',
chunkFilename: IS_PRODUCTION ? '[name].[contenthash:8].chunk.js' : '[name].chunk.js', chunkFilename: IS_PRODUCTION ? '[name].[contenthash:8].chunk.js' : '[name].chunk.js',
globalObject: 'this', // allow HMR and web workers to play nice globalObject: 'this', // allow HMR and web workers to play nice
...@@ -449,11 +458,11 @@ module.exports = { ...@@ -449,11 +458,11 @@ module.exports = {
new CopyWebpackPlugin([ new CopyWebpackPlugin([
{ {
from: path.join(ROOT_PATH, 'node_modules/pdfjs-dist/cmaps/'), from: path.join(ROOT_PATH, 'node_modules/pdfjs-dist/cmaps/'),
to: path.join(ROOT_PATH, 'public/assets/webpack/cmaps/'), to: path.join(WEBPACK_OUTPUT_PATH, 'cmaps/'),
}, },
{ {
from: path.join(ROOT_PATH, 'node_modules/@sourcegraph/code-host-integration/'), from: path.join(ROOT_PATH, 'node_modules', SOURCEGRAPH_PACKAGE, '/'),
to: path.join(ROOT_PATH, 'public/assets/webpack/sourcegraph/'), to: SOURCEGRAPH_OUTPUT_PATH,
ignore: ['package.json'], ignore: ['package.json'],
}, },
{ {
...@@ -461,7 +470,7 @@ module.exports = { ...@@ -461,7 +470,7 @@ module.exports = {
ROOT_PATH, ROOT_PATH,
'node_modules/@gitlab/visual-review-tools/dist/visual_review_toolbar.js', 'node_modules/@gitlab/visual-review-tools/dist/visual_review_toolbar.js',
), ),
to: path.join(ROOT_PATH, 'public/assets/webpack'), to: WEBPACK_OUTPUT_PATH,
}, },
]), ]),
...@@ -555,6 +564,8 @@ module.exports = { ...@@ -555,6 +564,8 @@ module.exports = {
'process.env.IS_EE': JSON.stringify(IS_EE), 'process.env.IS_EE': JSON.stringify(IS_EE),
// This one is used to check against "EE" properly in application code // This one is used to check against "EE" properly in application code
IS_EE: IS_EE ? 'window.gon && window.gon.ee' : JSON.stringify(false), IS_EE: IS_EE ? 'window.gon && window.gon.ee' : JSON.stringify(false),
// This is used by Sourcegraph because these assets are loaded dnamically
'process.env.SOURCEGRAPH_PUBLIC_PATH': JSON.stringify(SOURCEGRAPH_PUBLIC_PATH),
}), }),
/* Pikaday has a optional dependency to moment. /* Pikaday has a optional dependency to moment.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment