【问题标题】:Ember 1.13.1 vendor/assets not loadingEmber 1.13.1 供应商/资产未加载
【发布时间】:2015-10-02 09:09:55
【问题描述】:

编辑

问题似乎在于 brocfile.js 而不是迁移到 ember-cli-build.js。本文一扫而光:https://github.com/ember-cli/ember-cli/blob/master/TRANSITION.md.

我正在学习 ember-cli 101 教程,我们应该从 picnic 和 fontello 获取资产,但如果我转到 http://localhost:4200/assets/vendor.css,资产不会被识别/加载。事实上,如果我去那里,Ember 控制台根本不会检测到 Ember 应用程序。

我认为这可能与我所做的内容安全政策更改有关,只是为了使其不会引发违规行为:

config/environment.js:

contentSecurityPolicy: {
  'default-src': "'none'",
  'script-src': "'self' 'unsafe-inline' 'unsafe-eval'",
  'font-src': "'self'",
  'connect-src': "'self'",
  'img-src': "'self'",
  'style-src': "'self' 'unsafe-inline'",
  'frame-src': "'none'"
}

Brocfile.js:

var EmberApp = require('ember-cli/lib/broccoli/ember-app');

var app = new EmberApp({});

app.import('vendor/fontello/fontello.css');
app.import('vendor/fontello/font/fontello.ttf', {
  destDir: 'assets/fonts'
});
app.import('vendor/fontello/font/fontello.eot', {
  destDir: 'assets/fonts'
});
app.import('vendor/fontello/font/fontello.svg', {
  destDir: 'assets/fonts'
});
app.import('vendor/fontello/font/fontello.woff', {
  destDir: 'assets/fonts'
});

app.import('bower_components/picnic/releases/plugins.min.css');
app.import('bower_components/picnic/releases/picnic.min.css');

module.exports = app.toTree();


Bower.json includes: 

    "picnic": "~3.3.1"

我的目录结构是:

Brocfile.js
bower_components
    --> picnic 
bower.json
vendor
   --> fontello
            --> font 
                  --> fontello.eot / .svg .ttf .woff 

教程的源代码在这里:https://github.com/abuiles/borrowers

是的,我通过 Bower 安装并重新启动了服务器。

【问题讨论】:

  • 这不是 Ember 的错,SPA 具有更困难的抽象层。我想我也面临同样的问题,brb。
  • 也许只是野餐。我不知道。我必须学习 SPA,但发现它们并不容易上手。

标签: javascript ember.js


【解决方案1】:

这是一个ember-cli 1.13.0 问题,在0.2.7 中它仍然有效。公开问题:https://github.com/ember-cli/ember-cli/issues/4446

【讨论】:

  • 好的,这就解释了。谢谢你。我会密切关注这个问题。
【解决方案2】:

按照相同的教程,我遇到了同样的问题。

我发现如果你使用 broccoli 命令行和命令“broccoli build dist”,broccoli 会创建一个带有字体的新 dist 文件夹(一旦你删除或备份了以前的文件夹)使用 fontello 字体的文件夹,并按照应有的方式使用 picnic 文件的数据写入 vendor.css。

但是,如果您再次运行 ember 服务器,它会删除字体文件夹并将 vendor.css 再次留空。

目前是我发现的全部。

【讨论】:

猜你喜欢
  • 2023-03-15
  • 1970-01-01
  • 1970-01-01
  • 2011-11-14
  • 2012-04-21
  • 2012-12-21
  • 2014-11-16
  • 2013-10-12
  • 1970-01-01
相关资源
最近更新 更多