mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-18 10:46:31 +00:00
[Plugin] Plugin context (#9439)
* Pass more stuff to window * Expose form functions to plugin context * Breaking: Render plugin component in context tree - Required due to createRoot function - Adds necessary context providers * Fix context * Provide MantineThemeContext * Bundle mantine/core * Hack for useNavigate within ApiForm - Errors out if called within plugin context - Workaround to catch the error * Update build cmd * Define config for building "Library" mode * Update package.json * Add basic index file * Factor out ApiEndpoints * factor out ModelType * Factor out role enums * Further refactoring * More refactoring * Cleanup * Expose apiUrl function * Add instance data to plugin context type def * Tweaks for loading plugin components - LanguageContext must be on the inside * Tweak StylishText * Externalize notifications system * Update lingui config * Add functions for checking plugin interface version * Extract package version at build time * Enhance version checking * Revert variable name change * Public package * Add README.md * adjust packge name * Adjust name to include org * Update project files * Add basic changelog info * Refactoring to expose URL functions * Refactor navigation functions * Update package and README * Improve navigateToLink function * Refactor stylish text - Move into ./lib - Do not require user state * Revert changes - StylishText throws error in plugin - Low priority, can work out later * expose function to refresh page index * Provide RemoteComponent with a method to reload itself * Bump version * Cleanup tests * Prevent duplicate --emptyOutDir arg * Tweak playwright tests * Expose role and permission enums * Fix imports * Updated docs * Fix spelling, typos, etc * Include more package version information * Expose more version context * Cleanup * Probably don't need hooks * Fix links * Docs updates * Fix links
This commit is contained in:
@@ -6,13 +6,12 @@ import license from 'rollup-plugin-license';
|
||||
import { defineConfig, splitVendorChunkPlugin } from 'vite';
|
||||
import istanbul from 'vite-plugin-istanbul';
|
||||
|
||||
import { __INVENTREE_VERSION_INFO__ } from './version-info';
|
||||
|
||||
// Detect if the current environment is WSL
|
||||
// Required for enabling file system polling
|
||||
const IS_IN_WSL = platform().includes('WSL') || release().includes('WSL');
|
||||
|
||||
// Detect if code coverage is enabled (runs in GitHub CI)
|
||||
const IS_COVERAGE = !!process.env.VITE_COVERAGE_BUILD;
|
||||
|
||||
if (IS_IN_WSL) {
|
||||
console.log('WSL detected: using polling for file system events');
|
||||
}
|
||||
@@ -37,7 +36,7 @@ export default defineConfig(({ command, mode }) => {
|
||||
includePrivate: true,
|
||||
multipleVersions: true,
|
||||
output: {
|
||||
file: '../backend/InvenTree/web/static/web/.vite/dependencies.json',
|
||||
file: `${OUTPUT_DIR}/.vite/dependencies.json`,
|
||||
template(dependencies) {
|
||||
return JSON.stringify(dependencies);
|
||||
}
|
||||
@@ -45,7 +44,7 @@ export default defineConfig(({ command, mode }) => {
|
||||
}
|
||||
}),
|
||||
istanbul({
|
||||
include: 'src/*',
|
||||
include: ['src/*', 'lib/*'],
|
||||
exclude: ['node_modules', 'test/'],
|
||||
extension: ['.js', '.ts', '.tsx'],
|
||||
requireEnv: true
|
||||
@@ -62,7 +61,12 @@ export default defineConfig(({ command, mode }) => {
|
||||
build: {
|
||||
manifest: true,
|
||||
outDir: OUTPUT_DIR,
|
||||
sourcemap: IS_COVERAGE
|
||||
sourcemap: true
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@lib': '/lib'
|
||||
}
|
||||
},
|
||||
server: {
|
||||
proxy: {
|
||||
@@ -70,6 +74,11 @@ export default defineConfig(({ command, mode }) => {
|
||||
target: 'http://localhost:8000',
|
||||
changeOrigin: true,
|
||||
secure: true
|
||||
},
|
||||
'/static': {
|
||||
target: 'http://localhost:8000',
|
||||
changeOrigin: true,
|
||||
secure: true
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -77,6 +86,9 @@ export default defineConfig(({ command, mode }) => {
|
||||
// Ref: https://github.com/vitejs/vite/issues/1153#issuecomment-785467271
|
||||
usePolling: IS_IN_WSL
|
||||
}
|
||||
},
|
||||
define: {
|
||||
...__INVENTREE_VERSION_INFO__
|
||||
}
|
||||
};
|
||||
});
|
||||
|
Reference in New Issue
Block a user