Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Add ability to generate absolute urls when referencing templates and css files #1599

Closed
PaulAnnekov opened this issue Nov 18, 2014 · 1 comment
Labels

Comments

@PaulAnnekov
Copy link

Suppose I have a following project structure:

- myproject
  - lib
      - components
          - comp1
              comp1.html
              comp1.dart
              comp1.css
          - comp2
              ...
  - web
      index.html

My comp1.dart look like:

...
@Component(
    selector: 'comp1',
    templateUrl: 'comp1.html',
    cssUrl: 'comp1.css')
class Comp1Component {
  ...
}

After pub build transformer will generate packages/myproject/components/comp1/comp1.html link for comp1.html and the same link but with different extension for comp1.css.

And it works perfectly until your site does not use routes. When you begin to use routes browser tries to download files like this http://myproject.local/about_us/packages/myproject/components/comp1/comp1.html for url http://myproject.local/about_us/. It's totally wrong.

Why relative urls sucks:

  1. It turns out that the same resource gets from 100500 urls depending on site url. It's bad practise. I think that it leads to problems with files cache in browser and many others. It won't understand that it's the same resource.
  2. They don't work in production. pub serve handles such madness but it's not intended for production. We use something more powerful, e.g. nginx.

In my opinion we need an option to generate absolute urls. It might be on by default at least for build.

@naomiblack
Copy link
Contributor

@chirayuk can you please update with more information on URLs and routing in 1.x?

TedSander pushed a commit to TedSander/angular.dart that referenced this issue Jan 18, 2015
… relative

Makes resolved URLs absolute instead of relative. With this determination of
URLs is not relative to the current browser path, which was one of the problems
this code is trying to solve.

Closes dart-archive#1599
TedSander pushed a commit to TedSander/angular.dart that referenced this issue Jan 18, 2015
… relative

Makes resolved URLs absolute instead of relative. With this determination of
URLs is not relative to the current browser path, which was one of the problems
this code is trying to solve.

Closes dart-archive#1599
TedSander pushed a commit to TedSander/angular.dart that referenced this issue Jan 18, 2015
Makes resolved type URLs absolute instead of relative. When they are relative
it is difficult to reuse components. Using pub serve relative URLs are resolved
because pub does some magic to allow add symlinks to the packages directory
where needed. In production relative URLs make it difficult to add file handlers
to the locations that are needed, as the location will be determined based on
the current browser path or route. It also makes the template cache harder to
populate because the same resource may need to be served from two separate
URLs.

Closes dart-archive#1599
rkirov pushed a commit that referenced this issue Jan 28, 2015
Makes resolved type URLs absolute instead of relative. When they are relative
it is difficult to reuse components. Using pub serve relative URLs are resolved
because pub does some magic to allow add symlinks to the packages directory
where needed. In production relative URLs make it difficult to add file handlers
to the locations that are needed, as the location will be determined based on
the current browser path or route. It also makes the template cache harder to
populate because the same resource may need to be served from two separate
URLs.

Closes #1599
rkirov pushed a commit that referenced this issue Jan 28, 2015
Makes resolved type URLs absolute instead of relative. When they are relative
it is difficult to reuse components. Using pub serve relative URLs are resolved
because pub does some magic to allow add symlinks to the packages directory
where needed. In production relative URLs make it difficult to add file handlers
to the locations that are needed, as the location will be determined based on
the current browser path or route. It also makes the template cache harder to
populate because the same resource may need to be served from two separate
URLs.

Closes #1599
TedSander pushed a commit to TedSander/angular.dart that referenced this issue Jan 30, 2015
Makes resolved type URLs absolute instead of relative. When they are relative
it is difficult to reuse components. Using pub serve relative URLs are resolved
because pub does some magic to allow add symlinks to the packages directory
where needed. In production relative URLs make it difficult to add file handlers
to the locations that are needed, as the location will be determined based on
the current browser path or route. It also makes the template cache harder to
populate because the same resource may need to be served from two separate
URLs.

Closes dart-archive#1599
rkirov pushed a commit that referenced this issue Feb 2, 2015
Makes resolved type URLs absolute instead of relative. When they are relative
it is difficult to reuse components. Using pub serve relative URLs are resolved
because pub does some magic to allow add symlinks to the packages directory
where needed. In production relative URLs make it difficult to add file handlers
to the locations that are needed, as the location will be determined based on
the current browser path or route. It also makes the template cache harder to
populate because the same resource may need to be served from two separate
URLs.

Closes #1599
@rkirov rkirov closed this as completed in f55b6bc Feb 2, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants