Skip to content

Commit

Permalink
feat: proxy to backend (JS/TS related css are loaded via the script =…
Browse files Browse the repository at this point in the history
…> so empty css in that case)
  • Loading branch information
theus77 committed Oct 11, 2024
1 parent dfca236 commit 98db826
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Empty file.
16 changes: 16 additions & 0 deletions EMS/admin-ui-bundle/assets/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ import { resolve } from 'path'
import inject from '@rollup/plugin-inject'

export default defineConfig({
server: {
proxy: {
'/index.php': {
target: 'http://127.0.0.1:8881',
changeOrigin: false,
secure: false,
xfwd: true,
},
'/bundles': {
target: 'http://127.0.0.1:8881',
changeOrigin: false,
secure: false,
xfwd: true,
},
},
},
plugins: [
inject({
jQuery: 'jquery',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ public function applyVersion(string $path): string
private function getManifestPath(string $path): string
{
if (!isset($this->manifestData)) {
$manifestPath = $this->fileLocator->locate('@EMSAdminUIBundle/Resources/public/.vite/manifest.json');
try {
$manifestPath = $this->fileLocator->locate('@EMSAdminUIBundle/Resources/public/.vite/manifest.json');
} catch (\Throwable) {
if (\preg_match('/(?<path>.*\.(js|ts|cjs))(\.(?<index>[0-9]+))?\.css$/', $path)) {
return 'css/empty.css';
}
return $path;
}
if (!\is_file($manifestPath)) {
throw new RuntimeException(\sprintf('Asset manifest file "%s" does not exist. Did you forget to build the assets with npm or yarn?', $manifestPath));
}
Expand Down

0 comments on commit 98db826

Please sign in to comment.