惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
Security Latest
Security Latest
C
Cisco Blogs
P
Palo Alto Networks Blog
Know Your Adversary
Know Your Adversary
Project Zero
Project Zero
C
Cyber Attacks, Cyber Crime and Cyber Security
NISL@THU
NISL@THU
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Secure Thoughts
P
Privacy International News Feed
V
Vulnerabilities – Threatpost
D
Docker
Google Online Security Blog
Google Online Security Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Recent Announcements
Recent Announcements
T
The Exploit Database - CXSecurity.com
G
Google Developers Blog
Schneier on Security
Schneier on Security
小众软件
小众软件
爱范儿
爱范儿
GbyAI
GbyAI
J
Java Code Geeks
T
Tailwind CSS Blog
Cisco Talos Blog
Cisco Talos Blog
The Hacker News
The Hacker News
D
DataBreaches.Net
Blog — PlanetScale
Blog — PlanetScale
TaoSecurity Blog
TaoSecurity Blog
MyScale Blog
MyScale Blog
B
Blog RSS Feed
Cyberwarzone
Cyberwarzone
有赞技术团队
有赞技术团队
Martin Fowler
Martin Fowler
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Securelist
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Y
Y Combinator Blog
S
Schneier on Security
Latest news
Latest news
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 叶小钗
F
Fortinet All Blogs
M
MIT News - Artificial intelligence
PCI Perspectives
PCI Perspectives
V
V2EX
V2EX - 技术
V2EX - 技术
O
OpenAI News
W
WeLiveSecurity

Ember.js Blog

Ember 7.0 Released Announcing the Official TypeScript Types Public Preview Accessibility Working Group Update The 2020 Ember Roadmap Countdown to The New Year - Built-in Addons Countdown to The New Year - Ember Exam Countdown to The New Year - Ember Code Snippet Countdown to The New Year - Ember Changeset Countdown to The New Year - Ember In Viewport Countdown to The New Year - Ember CLI Update Countdown to The New Year - Ember Template Invocation Location Countdown to The New Year - Ember CLI TypeScript Countdown to The New Year - Ember Bootstrap and Ember Paper Countdown to The New Year - Ember CSS Modules Countdown to The New Year - Ember Mapbox GL Countdown to The New Year - Ember Shepherd Countdown to The New Year - Ember Template Lint Countdown to The New Year - Ember Composable Helpers Countdown to The New Year - Ember Leaflet Countdown to The New Year - Ember Intl Countdown to The New Year - Ember Test Selectors Countdown to The New Year - Ember Power Select Countdown to The New Year - Ember Simple Auth Countdown to The New Year - Ember SVG Jar Countdown to The New Year - Ember Page Title Countdown to The New Year- Ember A11Y Testing Countdown to The New Year - Ember Angle Brackets Codemod Countdown to The New Year - Ember CLI Sass Countdown to The New Year - Ember Animated Countdown to The New Year - Ember Auto Import Countdown to The New Year - Ember Concurrency Countdown to The New Year - Ember Tether Countdown to The New Year - Ember Modifier Countdown to The New Year - Ember CLI Mirage Countdown to The New Year - Ember Sortable Coming Soon in Ember Octane - Part 5: Glimmer Components Coming Soon in Ember Octane - Part 4: Modifiers Coming Soon in Ember Octane - Part 3: Tracked Properties Coming Soon in Ember Octane - Part 2: Angle Brackets & Named Arguments Preview Weekend: 2019 Ember Community Survey Coming Soon in Ember Octane - Part 1: Native Classes First Annual DecEmber Event! 2018 Ember Community Survey 2017 Ember Community Survey Announcing The Glimmer 2 Alpha 2016 Ember Community Survey Announcing Ember Core Team Face to Face, January 2016 Ember.js 1.13.0 and 2.0 Beta Released Another Ember 2.x Status Update Ember.js 1.12 and 1.13 Beta (Glimmer!) Released Ember.js 1.11.1 Released Ember.js 1.11.0 and 1.12 Beta Released Ember.js 1.10.0 and 1.11 Beta Released Compiling templates with Ember 1.10 Core Team Meeting Minutes - 2014/08/01 Core Team Meeting Minutes - 2014/08/14 Core Team Meeting Minutes - 2014/09/12 Cleaning Up Github Issues Core Team Meeting Minutes - 2014/07/11 Core Team Meeting Minutes - 2014/07/25 Ember 1.6.0 and 1.7 Beta Released Core Team Meeting Minutes - 2014/06/13 Core Team Meeting Minutes - 2014/06/20 Core Team Meeting Minutes - 2014/06/27 Core Team Meeting Minutes - 2014/06/06 Core Team Meeting Minutes - 2014/04/25 Core Team Meeting Minutes - 2014/04/04 Ember 1.5.0 and 1.6 Beta Released Core Team Meeting Minutes - 2014/03/07 Core Team Meeting Minutes - 2014/03/14 Core Team Meeting Minutes - 2014/03/21 Core Team Meeting Minutes - 2014/02/28 Core Team Meeting Minutes - 2014/02/21 Core Team Meeting Minutes - 2014/02/14 Ember 1.4.0 and 1.5 Beta Released Core Team Meeting Minutes - 2014/01/27 Core Team Meeting Minutes - 2014/01/31 Core Team Meeting Minutes - 2014/02/07 Core Team Meeting Minutes - 2014/01/17 Core Team Meeting Minutes - 2014/01/03 Ember 1.3.0 and 1.4 Beta Released Core Team Meeting Minutes - 2013/12/20 Core Team Meeting Minutes - 2013/12/06 Ember 1.2.0 and 1.3 Beta Released Ember 1.1.2 Released Ember 1.1.1 and 1.2 Beta Released Ember 1.0 Released Ember 1.0 RC8 Released Ember 1.0 RC7 Released Ember 1.0 RC6.1, RC5.1, RC4.1, RC3.1, RC2.1 RC1.1 Released Ember 1.0 RC6 Ember 1.0 RC5 Ember 1.0 RC4 Ember 1.0 RC3 Announcing the Ember.js Security Policy Ember 1.0 RC2 Ember 1.0 RC Ember 1.0 Prerelease 2 Ember 1.0 Prerelease
Upcoming deprecation of baseURL in Ember CLI 2.7
2016-04-28 · via Ember.js Blog

The baseURL configuration option and the accompanying <base> tag in Ember CLI applications are often and tragically misunderstood. There have been at least 67 issues opened for Ember CLI referencing baseURL, making it one of the most common points of discussion. As a result, in Ember CLI's canary channel, we have deprecated baseURL and removed the default <base> inside of index.html. The intent is that this change will be released with Ember CLI 2.7 stable in roughly 10 weeks.

Existing applications are able to continue using baseURL with a deprecation warning. If you are eager to adopt this change, you should note that the removal of the <base> tag may impact how your application is deployed, and if so, will likely require some small migration effort, detailed below.

This is the culmination of a lot of research and work by Tobias Bieniek and we're incredibly grateful for his efforts.

What was it?

baseURL allowed an Ember application and assets to be deployed to a subdirectory without requiring rewriting of asset URLs, instead allowing them to be included relatively. For example given an HTML file:

<head>
  <base href="http://emberapp.example.com/path/to/application/">
  <link rel="stylesheet" href="assets/style.css">
</head>
<body>
  <img src="assets/images/image.png">
</body>

The style would be fetched from http://emberapp.example.com/path/to/application/assets/style.css, and the image from http://emberapp.example.com/path/to/application/assets/images/image.png. If you are curious, here is a good read on the base tag. In short, baseURL is the configuration property Ember CLI used to identify what value to put in the <base href="..." /> tag included in index.html. This determined where assets for the application should be loaded from, including app.js, vendor.js, app.css, and anything else that isn't specified with a fully-qualified path.

Why are we deprecating it?

Variations on the baseURL solution has been Ember CLIs default asset prefixing behavior for two years. There are a number of reasons why we're moving away from this pattern, but a few things really made it unnecessarily complicated.

API Design Bugs

Since we added this feature two years ago apps can have both baseURL and rootURL configuration values. These two names are far too similar and do things which are far too similar. Where baseURL identified the asset prefix of an application, rootURL identifies the path at which an Ember application is served so Ember's router can know which path segments to ignore.

Implicit Behavior

Not only are there two confusing configuration options, but if only one of baseURL or rootURL was set Ember CLI made a best-effort guess at populating the other's value. This implicit behavior violated the principle of least surprise for many people. An explicit requirement for both values always being set and clearer documentation would have averted some of the pain but would have added additional things to the learning curve.

Integration With Other Applications

Not every Ember application is full green field development. If you happened to have legacy user-generated HTML, or other data containing relative links, this didn't play nicely with the <base> tag. Rewriting this content is an option, but incurs cost and bugs that can be avoided by not including the <base> tag.

SVG

Worst of all, and something that we can't code or document around, SVG <use> elements break in an unexpected way when used with a <base> tag. It turns out that the relatively common pattern of <use xlink:xhref="#__SVG_ID__"></use> referencing a fragment identifier doesn't play nicely with the <base> tag. We like to play nicely with the web ecosystem and this fault is the final straw that resulted in the decision of removing the <base> tag.

How Do I Migrate?

Existing applications are able to continue using baseURL with a deprecation warning. For users who do want to migrate, the steps depend primarily on how your application is deployed. It's our goal is to make it easy for you to achieve the same behaviors you've had in the past.

New Applications

If you're starting a new application using an Ember CLI canary (or eventually 2.7 stable) everything should work correctly out of the box. We've been very careful to make sure that the out of the box experience is as smooth as possible. For the built-in development server all assets will be served at the rootURL. Relative URLs will continue to work fine inside of your CSS files and paths to assets included in your templates, index.html, or inserted via {{content-for}} should specify a root-relative path.

Upgrading

If you are upgrading your application to the new version of Ember CLI (canary with this change, or eventually 2.7 stable), you should pay close attention to the configuration changes inside of the modified blueprint files. We have also inserted deprecation warnings which will hopefully guide you through each of these changes.

The primary migration effort is that you should expect to adjust any relative paths which appear in your templates, are inserted via {{content-for}}, or directly present in index.html. Because you will be serving index.html from the server for any arbitrary route in your application you must modify these to be either a fully-qualified path or a root-relative URL.

As an example, given this configuration where you have configured a different rootURL and baseURL:

// config/environment.js
var ENV = {
  /* ... */
  rootURL: '/path/to/application/',
  baseURL: '/assets/go/here/'
  /* ... */
}

You would remove the baseURL option and modify your templates like so:

{{!-- Old: --}}
<img src="images/logo.png" />

{{!-- New: --}}
<img src="/assets/go/here/images/logo.png" />

How To Use a CDN

One of the most common use cases for baseURL was pointing to assets on a CDN. After this change to remove baseURL you should use the prepend option for broccoli-asset-rev which is included with Ember CLI apps by default. For example, in ember-cli-build.js:

// ember-cli-build.js
var app = new EmberApp(defaults, {
  // Add options here
  fingerprint: {
    prepend: 'https://cdn.example.com/'
  }
});

Note that the prepend option only applies when doing production builds via something like ember build --prod. Given the above example, and this input:

// config/environment.js
var ENV = {
  /* ... */
  rootURL: '/path/to/application/'
  /* ... */
}
<!-- Snipped from the <head> of the new `index.html` blueprint.  -->
<link rel="stylesheet" href="{{rootURL}}assets/vendor-f98f3bd4c08d05341cb6ba70451a6558.css">
<link rel="stylesheet" href="{{rootURL}}assets/app-name.css">

The output for asset paths in index.html would look something like:

<link rel="stylesheet" href="https://cdn.example.com/path/to/application/assets/vendor-e37004361bf9cda2ab3379d96c9eba4b.css">
<link rel="stylesheet" href="https://cdn.example.com/path/to/application/assets/app-name-dc477601773d4043b0c461b2a0ae8aef.css">

Note that rootURL is present as part of the path for the CDN-hosted assets inside of index.html. rootURL is an Ember CLI concept primarily concerned with supporting the behavior of ember server.

Configuring the Router

We also use the setting for rootURL at runtime in the application's router:

// app/router.js
import Ember from 'ember';
import config from './config/environment';

const Router = Ember.Router.extend({
  rootURL: config.rootURL
});

In most cases this does exactly what you want it to do. However, if you wish to mount the application at a different place than the Ember CLI rootURL specifies for its ember serve location, you may add an additional property in your config, routerRootURL, to specify the path that your application will live at runtime.

// config/environment.js
var ENV = {
  /* ... */
  rootURL: '/',
  routerRootURL: '/path/to/application/'
  /* ... */
}

You would then reference that inside of your application's router like so:

const Router = Ember.Router.extend({
  rootURL: config.routerRootURL
});

This provides a method to remove the '/path/to/application/' prefix from assets inside of index.html which will be served from a CDN.

CSS, Fonts, and Other Static Assets

Depending upon how these were included into an application, their paths may need to be adjusted. Assets like these are often handled outside the Ember CLI build pipeline, but do check to make sure that everything is works as expected.

Addon Consumption and Development

It's possible that you have addons which rely on rewriting asset URLs. If there is any impact, it is most likely going to impact users of ember-cli-deploy. Please let us know what you discover during this canary/beta process, we'd like to see what each addon is attempting to accomplish and make sure we can support that use case.

Everything is Broken! Help!

If for some reason removing baseURL and the default <base> tag causes problems, you can still add a <base> tag directly to your index.html file:

<base href="/what/your/baseURL/was/" />

This can be useful to address relative URLs which are being inserted via templates, index.html, or {{content-for}}. For pathing to your built CSS and JS assets use the method described for CDNs.

How Can I Try This?

Using our new release channel setup, you can try this change by upgrading your Ember CLI app to the canary channel:

npm install --save-dev ember-cli/ember-cli#canary

If you discover any problems with this change please file an issue, we'll be paying especially close attention to this topic.