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

wrong assets url if rootUrl is set to empty string '' #540

Open
patricklx opened this issue Oct 5, 2022 · 6 comments
Open

wrong assets url if rootUrl is set to empty string '' #540

patricklx opened this issue Oct 5, 2022 · 6 comments

Comments

@patricklx
Copy link

patricklx commented Oct 5, 2022

because ensureTrailingSlash for rootUrl will return a "/" and will end up adding a leading slash to the full url

@patricklx
Copy link
Author

this is supported on ember-cli ember-cli/ember-cli#6182

@conormag
Copy link

conormag commented Jan 9, 2023

can't deploy app to github-pages or elsewhere where relative path is needed without a leading '/'

@jelhan
Copy link
Contributor

jelhan commented Mar 7, 2023

I'm running into the same issue. Tried setting publicAssetURL to an empty string as well. But it did not help.

I don't know the deployment location at build time. So I need to use a relative URL. Configured Ember's router to use hash location strategy. So no need for absolute URL. Just need to figure out how to configure Ember Auto Import / Webpack to use relative URLs for assets as well.

@jelhan
Copy link
Contributor

jelhan commented Mar 7, 2023

Just figured out that it's working if setting publicAssetURL to assets/.

diff --git a/website/ember-cli-build.js b/website/ember-cli-build.js
index 9b5e85d..978f723 100644
--- a/website/ember-cli-build.js
+++ b/website/ember-cli-build.js
@@ -4,6 +4,9 @@ const EmberApp = require('ember-cli/lib/broccoli/ember-app');
 
 module.exports = function (defaults) {
   let app = new EmberApp(defaults, {
+    autoImport: {
+      publicAssetURL: 'assets/',
+    },
     'ember-bootstrap': {
       whitelist: ['bs-navbar', 'bs-collapse'],
     },

@jelhan
Copy link
Contributor

jelhan commented Mar 9, 2023

Just figured out that it's working if setting publicAssetURL to assets/.

diff --git a/website/ember-cli-build.js b/website/ember-cli-build.js
index 9b5e85d..978f723 100644
--- a/website/ember-cli-build.js
+++ b/website/ember-cli-build.js
@@ -4,6 +4,9 @@ const EmberApp = require('ember-cli/lib/broccoli/ember-app');
 
 module.exports = function (defaults) {
   let app = new EmberApp(defaults, {
+    autoImport: {
+      publicAssetURL: 'assets/',
+    },
     'ember-bootstrap': {
       whitelist: ['bs-navbar', 'bs-collapse'],
     },

This is not working if running ember test. 😭

@patricklx
Copy link
Author

That's right. But in tests it looks to work without setting the public asset url. So i wrapped it in an if env !== test

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

3 participants