Should not be merged before https://github.com/medusajs/medusa/pull/10895 **What** - Introduces a new `plugin` command to `admin-bundler`, currently not used anywhere but will be called from `medusa build:plugin` - Discovers plugins with extensions and add passes the to `admin-vite-plugin`. - Updates `admin-vite-plugin` so its able to read built admin extensions. Resolves CMRC-830, CMRC-839
17 lines
413 B
TypeScript
17 lines
413 B
TypeScript
import { normalizePath, VALID_FILE_EXTENSIONS } from "../utils"
|
|
|
|
export function getRoute(file: string): string {
|
|
const importPath = normalizePath(file)
|
|
return importPath
|
|
.replace(/.*\/admin\/(routes)/, "")
|
|
.replace(/\[([^\]]+)\]/g, ":$1")
|
|
.replace(
|
|
new RegExp(
|
|
`/page\\.(${VALID_FILE_EXTENSIONS.map((ext) => ext.slice(1)).join(
|
|
"|"
|
|
)})$`
|
|
),
|
|
""
|
|
)
|
|
}
|