From c7368baa305c901496a1eb931c9feda741297cd0 Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Tue, 5 Mar 2024 15:21:00 +0100 Subject: [PATCH] feat(frontend): make enterprise work --- public/app/app.ts | 15 +++++++-------- vite.config.ts | 5 ++--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/public/app/app.ts b/public/app/app.ts index b4e5caf3cc4..1023438c215 100644 --- a/public/app/app.ts +++ b/public/app/app.ts @@ -104,15 +104,14 @@ import { createSystemVariableAdapter } from './features/variables/system/adapter import { createTextBoxVariableAdapter } from './features/variables/textbox/adapter'; import { configureStore } from './store/configureStore'; -// import symlinked extensions -// TODO: Vite has no require.context support yet. Enterprise will need some thought. -// const extensionsIndex = require.context('.', true, /extensions\/index.ts/); -const extensionsIndex = (key: string) => ({}); -extensionsIndex.keys = () => []; +type ExtensionExports = { + init: () => void; + addExtensionReducers: () => void; +}; -const extensionsExports = extensionsIndex.keys().map((key) => { - return extensionsIndex(key); -}); +// import symlinked extensions (use glob so vite doesn't error if no files are found) +const extensions: Record = import.meta.glob('./extensions/index.ts', { eager: true }); +const extensionsExports = Object.values(extensions); if (process.env.NODE_ENV === 'development') { initDevFeatures(); diff --git a/vite.config.ts b/vite.config.ts index f1ff163188c..a94dcfb9807 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -15,7 +15,7 @@ export default defineConfig({ input: ['./public/app/index.ts', './public/sass/grafana.dark.scss', './public/sass/grafana.light.scss'], }, outDir: './build', - assetsDir: './', + assetsDir: './assets', }, server: { // vite binds to ipv6 by default... and that doesn't work for me locally on mac... @@ -61,14 +61,13 @@ export default defineConfig({ replacement: '@grafana/schema/src/$1', }, ], - extensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json'], }, }); /** This is a Vite plugin for handling angular templates. https://vitejs.dev/guide/api-plugin.html#simple-examples - + The webpack output from https://github.com/WearyMonkey/ngtemplate-loader looks like this: var code = "\n
\n\t
\n\t\t
\n"; Exports