ember-auto-import icon indicating copy to clipboard operation
ember-auto-import copied to clipboard

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

Open patricklx opened this issue 2 years ago • 6 comments

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

patricklx avatar Oct 05 '22 08:10 patricklx

this is supported on ember-cli https://github.com/ember-cli/ember-cli/pull/6182

patricklx avatar Oct 07 '22 08:10 patricklx

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

conormag avatar Jan 09 '23 12:01 conormag

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 avatar Mar 07 '23 14:03 jelhan

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 avatar Mar 07 '23 14:03 jelhan

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. :sob:

jelhan avatar Mar 09 '23 14:03 jelhan

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

patricklx avatar Mar 09 '23 14:03 patricklx