2014-09-21 5 views
8

그래서 저는 엠버 응용 프로그램에서 선제 적으로 플레이하고 싶습니다.ember-cli가 bower와 종속성을 추가합니다.

나는 그때

bower install typeahead.js 

내가 코드가 bower_components에 투입 된 것을 볼 수 있습니다 운영하는 CLI의 응용 프로그램 및 실행을 얻을. 의 라인을 정자에 설치하고 추가 - - 나는 문서를 읽기에서

Uncaught ReferenceError: Bloodhound is not defined 

을 얻을

/* global require, module */ 

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

var app = new EmberApp(); 

// Use `app.import` to add additional libraries to the generated 
// output files. 
// 
// If you need to use different assets in different 
// environments, specify an object as the first parameter. That 
// object's keys should be the environment name and the values 
// should be the asset to use in that environment. 
// 
// If the library that you are including contains AMD or ES6 
// modules that you would like to import into your application 
// please specify an object with the list of modules as keys 
// along with the exports of each module as its value. 

app.import('bower_components/typeahead.js/dist/typeahead.bundle.min.js'); 

module.exports = app.toTree(); 

가 작동하지 않습니다하지만 :

그때하여 brocfile에 다음을 추가 brocfile은 그것을 만족시키기에 충분해야합니까? 내가 잘못 읽었습니까? 아니면이 버그입니까? 내가 한 짓을

https://github.com/wayne-o/ember-cli-bootstrap

은 다음과 같습니다 :

ember new bootstrap-test 
bower install bootstrap 

그리고 추가 :

app.import('bower_components/bootstrap/dist/css/bootstrap.css'); 
app.import('bower_components/bootstrap/dist/js/bootstrap.js'); 

을에

나는이 문제를 보여줍니다 공공 GIT의 REPO을 만들었습니다 브로크 파일 ...

작동하지 않았습니다.

+0

typeahead.bundle.min.js에는 bloodhound가 포함되어야합니다. bloodhound.js 가져 오기를 시도하십시오. –

+0

여전히 오류가 발생합니다 :/ – iwayneo

+0

@drorb 문제를 수정하고 github에 repo를 추가하여 문제를 보여줍니다. – iwayneo

답변

5

당신은 Brocfile.js를 공유하지 않았지만 해당 파일의 끝에 module.exports = app.toTree(); 행 뒤에 종속성을 추가하면 비슷한 문제가 발생했습니다. 이 문서는 not terribly clear에 관한 것이지만, module.exports = app.toTree();은 항상 Brocfile.js의 마지막에 와야합니다. app.import() 문을이 줄 위로 이동하면 모든 것이 제대로 작동합니다.

업데이트

당신의 repo를 아래로 당기면 나는 몇 가지 문제를 발견했습니다. 첫 번째는 부트 스트랩 및 typeahead.js 용 bower 설치에 --save-dev을 전달해야 다른 사람이 repo를 푸시 다운 할 때 설치해야합니다. 빌드에 jshint 오류를 방지하기 위해 나는 또한 .jshintrc의 prefdef 섹션 "Bloodhound": true을 추가

"devDependencies": { 
    "bootstrap": "~3.2.0", 
    "typeahead.js": "~0.10.5" 
} 

: 그것은 당신의 bower.json이 같은 섹션을 추가합니다

"predef": { 
    "document": true, 
    "window": true, 
    "-Promise": true, 
    "Bloodhound": true 
    }, 

또한 대체 할 수 있습니다 $index.jsEmber.$으로 참조하는 경우 다른 jshint 오류가 발생하지 않습니다.

내가 이것을 한 번 수행하면 ember serve을 실행하고 Bloodhound 문제없이 앱을로드 할 수있었습니다.

+3

열쇠는 의존성을 추가 한 후 서버를 다시 시작해야한다는 것입니다. – iwayneo

+0

예, 그 역시 :) – Dhaulagiri

관련 문제