Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build not working #1

Closed
Creatz opened this issue Dec 14, 2021 · 4 comments
Closed

Build not working #1

Creatz opened this issue Dec 14, 2021 · 4 comments

Comments

@Creatz
Copy link

Creatz commented Dec 14, 2021

First of all, congratulations and thanks for the work done, nevertheless, I can't execute the build command

npx directus-extension build :

Error: Could not resolve './directus/app/src/utils/get-root-path' from src/interface.vue?vue&type=script&lang.ts
Error: Could not resolve './directus/app/src/utils/get-root-path' from src/interface.vue?vue&type=script&lang.ts
    at error (/Users/name/Desktop/directus-interface-uuid-file-image-main/node_modules/rollup/dist/shared/rollup.js:158:30)
    at ModuleLoader.handleResolveId (/Users/name/Desktop/directus-interface-uuid-file-image-main/node_modules/rollup/dist/shared/rollup.js:22336:24)
    at /Users/name/Desktop/directus-interface-uuid-file-image-main/node_modules/rollup/dist/shared/rollup.js:22310:26
@bnznt
Copy link

bnznt commented Dec 17, 2021

It failed at postinstall script. You can run that script manually. But there is another way to get it work.

  1. Create a file called get-root-path.ts in src folder with the following content:
export function getRootPath(): string {
	const path = window.location.pathname;
	const parts = path.split('/');
	const adminIndex = parts.indexOf('admin');
	const rootPath = parts.slice(0, adminIndex).join('/') + '/';
	return rootPath;
}

export function getPublicURL(): string {
	const path = window.location.href;
	const parts = path.split('/');
	const adminIndex = parts.indexOf('admin');
	const rootPath = parts.slice(0, adminIndex).join('/') + '/';
	return rootPath;
}
  1. Then open src/interface.vue and replace this line with import { getRootPath } from './get-root-path'

  2. Run npx directus-extension build again and you ready to go 🚀

By the way, thank @stouch for writing this extension. It saved my day.

@Creatz
Copy link
Author

Creatz commented Dec 17, 2021

Thank you very much for your answer,
It works perfectly!

@buzzeins
Copy link

Just opened a pull request https://github.com/stouch/directus-interface-uuid-file-image/pull/4/files#diff-053150b640a7ce75eff69d1a22cae7f0f94ad64ce9a855db544dda0929316519 with that solution in.
Also updated deps and removed unnecessary postinstall script. Maybe @stouch can review and merge it?

@stouch
Copy link
Owner

stouch commented Jul 30, 2023

Thanks @buzzeins ! I merged it 👍

@stouch stouch closed this as completed Jul 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants