Skip to content

Commit

Permalink
Move files back to public after turning off vite's publicDir feature,…
Browse files Browse the repository at this point in the history
… ensuring that ./scripts/start.sh and ./scripts/client-dev.sh still work
  • Loading branch information
rhystmills committed Jan 2, 2025
1 parent 2d40aff commit 9e8204a
Show file tree
Hide file tree
Showing 262 changed files with 26 additions and 103 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ metals.sbt
.bloop
.bsp/
.java-version
video-ui/build
**/manifest.json
.vite
17 changes: 5 additions & 12 deletions app/controllers/VideoUIApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,14 @@ class VideoUIApp(val authActions: HMACAuthActions, conf: Configuration, awsConfi

val jsFileName = "video-ui/build/app.js"

val jsAssetHost = sys.env.get("JS_ASSET_HOST")

val isHotReloading = jsAssetHost match {
case Some(_) if awsConfig.isDev => true
val isHotReloading = sys.env.get("RELOADING") match {
case Some("HOT") if awsConfig.isDev => true
case _ => false
}

val jsLocation = if (isHotReloading) {
jsAssetHost.get + jsFileName
} else {
routes.Assets.versioned(jsFileName).toString
}
val jsLocation = routes.Assets.versioned(jsFileName).toString


val stage = conf.get[String]("stage")
val composerUrl = awsConfig.composerUrl

val permissions = permissionsProvider.getAll(req.user)
Expand All @@ -54,7 +48,7 @@ class VideoUIApp(val authActions: HMACAuthActions, conf: Configuration, awsConfi
liveCapiProxyUrl = "/support/liveCapi",
composerUrl = composerUrl,
ravenUrl = conf.get[String]("raven.url"),
stage,
stage = conf.get[String]("stage"),
viewerUrl = awsConfig.viewerUrl,
permissions,
minDurationForAds = youtube.minDurationForAds,
Expand All @@ -71,7 +65,6 @@ class VideoUIApp(val authActions: HMACAuthActions, conf: Configuration, awsConfi
Json.toJson(clientConfig).toString(),
isHotReloading,
CSRF.getToken.value,
stage,
))
}

Expand Down
5 changes: 2 additions & 3 deletions app/views/VideoUIApp/app.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
clientConfigJson: String,
isHotReloading: Boolean,
csrf: String,
stage: String
)

@layout(title, isHotReloading, csrf) {
Expand All @@ -23,7 +22,7 @@ <h1>Loading...</h1>
}
<script type="module">window.global = window</script>

@if(stage == "DEV") {
@if(isHotReloading) {
<!-- Connect directly to Vite dev server in development -->
<!-- See https://vitejs.dev/guide/backend-integration.html -->
<script type="module">
Expand All @@ -36,7 +35,7 @@ <h1>Loading...</h1>
window.__vite_plugin_react_preamble_installed__ = true
</script>
<script type="module" src="http://localhost:5173/@@vite/client"></script>
<script type="module" src="http://localhost:5173/video-ui/src/app.jsx"></script>
<script type="module" src="http://localhost:5173/public/video-ui/src/app.jsx"></script>
} else {
<link rel="stylesheet" type="text/css" href="/build/index.css">
<script type="module" src="@jsFileLocation"></script>
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
"description": "media atom editor",
"scripts": {
"build": "tsc && vite build",
"build-dev": "webpack -o ./video-ui/build/ --config ./build_config/webpack.dev.conf.js --watch",
"client-dev": "vite",
"lint": "eslint video-ui/src/**/*.js",
"lint": "eslint public/video-ui/src/**/*.(js|ts)*",
"test": "jest"
},
"jest": {
"roots": [
"video-ui/src/test"
"public/video-ui/src/test"
],
"preset": "ts-jest/presets/js-with-ts"
},
Expand Down
68 changes: 0 additions & 68 deletions public/video-ui/.vite/manifest.json

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { saveStateVals } from '../../constants/saveStateVals';
import { isVideoPublished } from '../../util/isVideoPublished';
import { hasUnpublishedChanges } from '../../util/hasUnpublishedChanges';
import ScheduledLaunch from '../../components/ScheduledLaunch/ScheduledLaunch';
import ScheduledLaunch from '../ScheduledLaunch/ScheduledLaunch';
import { canonicalVideoPageExists } from '../../util/canonicalVideoPageExists';
import VideoUtils from '../../util/video';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { saveStateVals } from '../../constants/saveStateVals';
import Icon from '../../components/Icon';
import Icon from '../Icon';

export default class VideoSearch extends React.Component {
onSearch = e => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion video-ui/src/routes.jsx → public/video-ui/src/routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Router, Route, browserHistory, IndexRedirect, Redirect } from 'react-ro

import Search from './pages/Search';
import Video from './pages/Video';
import Upload from './pages/Upload/';
import Upload from './pages/Upload';
import Help from './pages/Help';
import Training from './pages/Training';
import ReactApp from './components/ReactApp';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { parseComposerDataFromImage } from './parseGridMetadata';
import { getStore } from '../util/storeAccessor';
import { getStore } from './storeAccessor';
import { impossiblyDistantDate } from '../constants/dates';
import VideoUtils from '../util/video';
import VideoUtils from './video';

export function getComposerData(video) {

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/client-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ set_node_version
printf "\n\rStarting Vite Dev Server... \n\r\n\r"
yarn run client-dev &
printf "\n\rStarting Play App... \n\r\n\r"
sbt $@ app/run
RELOADING=HOT sbt $@ app/run
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"forceConsistentCasingInFileNames": true,
},
"include": [
"video-ui/src/**/*",
"public/video-ui/src/**/*",
],
"exclude": [
"public/video-ui/build/**/*"
Expand Down
19 changes: 10 additions & 9 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';

export default defineConfig({
base: '',
plugins: [react()],
publicDir: false, // This feature is deactivated because the 'public' dir also has a special meaning for the Play framework
build: {
manifest: true,
rollupOptions: {
input: './video-ui/src/app.jsx',
input: './public/video-ui/src/app.jsx',
output: {
entryFileNames: `build/[name].js`,
chunkFileNames: `build/[name].js`,
assetFileNames: `build/[name].[ext]`
entryFileNames: `[name].js`,
chunkFileNames: `[name].js`,
assetFileNames: `[name].[ext]`
}
},
outDir: "./public/video-ui/",
outDir: "./public/video-ui/build",
emptyOutDir: true
},
server: {
origin: 'http://localhost:5173',
// We depend upon this port number in a few places, so fail fast if we cannot allocate it.
strictPort: true,
fs: {
allow: ['/video-ui/fonts', './']
allow: ['/public/video-ui/fonts', './']
}
}
})
});

0 comments on commit 9e8204a

Please sign in to comment.