Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
This repository was 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

Description

@PaulAnnekov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions