Skip to content

Commit

Permalink
PB-1176: Fix cesium static assets location
Browse files Browse the repository at this point in the history
During the build the cesium static assets were put into the root of the application.
This was an issue for our deployment strategy were we have all assets in a
versioned folder and were we first deploy the versioned folder before deploying
the entry point index.html that point to the versioned folder. This allow for
a pseudo atomic deployment.

So now all the cesium static assets have been placed into VERSION/cesium/ path.
  • Loading branch information
ltshb committed Dec 10, 2024
1 parent 403439d commit 7ae01a7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module.exports = {
globals: {
VITE_ENVIRONMENT: true,
__APP_VERSION__: true,
__CESIUM_STATIC_PATH__: true,
defineModel: 'readonly',
},
overrides: [
Expand Down
7 changes: 7 additions & 0 deletions src/config/map.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,10 @@ export const DEFAULT_FEATURE_COUNT_RECTANGLE_SELECTION = 50
* @type {Number}
*/
export const GPX_GEOMETRY_SIMPLIFICATION_TOLERANCE = 12.5 // meters

/**
* Path to the cesium static assets
*
* @type {string}
*/
export const CESIUM_STATIC_PATH = __CESIUM_STATIC_PATH__
4 changes: 2 additions & 2 deletions src/modules/map/components/cesium/CesiumMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ import GeoAdminGeoJsonLayer from '@/api/layers/GeoAdminGeoJsonLayer.class'
import GPXLayer from '@/api/layers/GPXLayer.class'
import KMLLayer from '@/api/layers/KMLLayer.class'
import { get3dTilesBaseUrl, getWmsBaseUrl, getWmtsBaseUrl } from '@/config/baseUrl.config'
import { DEFAULT_PROJECTION } from '@/config/map.config'
import { CESIUM_STATIC_PATH, DEFAULT_PROJECTION } from '@/config/map.config'
import { IS_TESTING_WITH_CYPRESS } from '@/config/staging.config'
import FeatureEdit from '@/modules/infobox/components/FeatureEdit.vue'
import FeatureList from '@/modules/infobox/components/FeatureList.vue'
Expand Down Expand Up @@ -207,7 +207,7 @@ export default {
beforeCreate() {
// Global variable required for Cesium and point to the URL where four static directories (see vite.config) are served
// https://cesium.com/learn/cesiumjs-learn/cesiumjs-quickstart/#install-with-npm
window['CESIUM_BASE_URL'] = '.'
window['CESIUM_BASE_URL'] = CESIUM_STATIC_PATH
// required for ol-cesium
window['Cesium'] = cesium
Expand Down
10 changes: 6 additions & 4 deletions vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ if (!appVersion) {
const __dirname = dirname(fileURLToPath(import.meta.url))
const cesiumSource = `${__dirname}/node_modules/cesium/Source`
const cesiumWorkers = '../Build/Cesium/Workers'
const cesiumStaticDir = `./${appVersion}/cesium/`

/**
* We use manual chunks to reduce the size of the final index.js file to improve startup
Expand Down Expand Up @@ -79,19 +80,19 @@ export default defineConfig(({ mode }) => {
targets: [
{
src: normalizePath(`${cesiumSource}/${cesiumWorkers}`),
dest: `./`,
dest: cesiumStaticDir,
},
{
src: normalizePath(`${cesiumSource}/Assets/`),
dest: `./`,
dest: cesiumStaticDir,
},
{
src: normalizePath(`${cesiumSource}/Widgets/`),
dest: `./`,
dest: cesiumStaticDir,
},
{
src: normalizePath(`${cesiumSource}/ThirdParty/`),
dest: `./`,
dest: cesiumStaticDir,
},
],
}),
Expand All @@ -106,6 +107,7 @@ export default defineConfig(({ mode }) => {
define: {
__APP_VERSION__: JSON.stringify(appVersion),
VITE_ENVIRONMENT: JSON.stringify(mode),
__CESIUM_STATIC_PATH__: JSON.stringify(cesiumStaticDir),
},
test: {
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
Expand Down

0 comments on commit 7ae01a7

Please sign in to comment.