2016-06-20 4 views
0

글쎄, 이상한 상황이 있습니다. 제 3 자의 lib 설치를위한 모든 가이드를 따랐습니다. 실제로 서비스를 실행하면 dis/vendor/redux에서 라이브러리를 볼 수 있습니다. 하지만 브라우저를 열면 앱이 작동하지 않고 개발자 도구의 리소스를 확인할 때 라이브러리가 존재하지 않습니다. 어디에서 문제를 찾아야합니까? 나는 그것이 dist 폴더에서 (webstorm에서) 라이브러리를 볼 수 있지만 그것이 브라우저에서 볼 수 없다는 것을 의미한다.Angular CLI 타사 라이브러리 설치가 실패했습니다.

// SystemJS configuration file, see links for more information 
// https://github.com/systemjs/systemjs 
// https://github.com/systemjs/systemjs/blob/master/docs/config-api.md 

/*********************************************************************************************** 
* User Configuration. 
**********************************************************************************************/ 
/** Map relative paths to URLs. */ 
const map: any = { 
    'redux': 'vendor/redux/dist' 
}; 

/** User packages configuration. */ 
const packages: any = { 
    'redux':{defaultExtension: 'js', main: 'redux.js'} 
}; 

//////////////////////////////////////////////////////////////////////////////////////////////// 
/*********************************************************************************************** 
* Everything underneath this line is managed by the CLI. 
**********************************************************************************************/ 
const barrels: string[] = [ 
    // Angular specific barrels. 
    '@angular/core', 
    '@angular/common', 
    '@angular/compiler', 
    '@angular/http', 
    '@angular/router', 
    '@angular/platform-browser', 
    '@angular/platform-browser-dynamic', 
    '@angular/router-deprecated', 

    // Thirdparty barrels. 
    'rxjs', 
    // App specific barrels. 
    'app', 
    'app/shared', 
    /** @cli-barrel */ 
]; 

const cliSystemConfigPackages: any = {}; 
barrels.forEach((barrelName: string) => { 
    cliSystemConfigPackages[barrelName] = { main: 'index' }; 
}); 

/** Type declaration for ambient System. */ 
declare var System: any; 

// Apply the CLI SystemJS configuration. 
System.config({ 
    map: { 
    '@angular': 'vendor/@angular', 
    'rxjs': 'vendor/rxjs', 
    'main': 'main.js' 
    }, 
    packages: cliSystemConfigPackages 
}); 

// Apply the user's configuration. 
System.config({ map, packages }); 

그리고 각-CLI-build.js : 그들은 제 3 자 libs와에 대한 더 나은 지원을 얻을 때까지

// Angular-CLI build configuration 
    // This file lists all the node_modules files that will be used in a build 
    // Also see https://github.com/angular/angular-cli/wiki/3rd-party-libs 

    /* global require, module */ 

    var Angular2App = require('angular-cli/lib/broccoli/angular2-app'); 

    module.exports = function(defaults) { 
     return new Angular2App(defaults, { 
     vendorNpmFiles: [ 
      'systemjs/dist/system-polyfills.js', 
      'systemjs/dist/system.src.js', 
      'zone.js/dist/**/*.+(js|js.map)', 
      'es6-shim/es6-shim.js', 
      'reflect-metadata/**/*.+(ts|js|js.map)', 
      'rxjs/**/*.+(js|js.map)', 
      '@angular/**/*.+(js|js.map)', 
      'redux/dist/**/*.js' 
     ] 
     }); 
    }; 
+0

'공급 업체/REDUX/DIST/redux.js', 어쩌면 당신은'형식을 추가 할 필요가 무엇 형식으로 만들 희망? – Sasxa

+0

'packages' 정의가 필요 없습니다. – dmackerman

답변

1

내가 당신에게 해결 방법을 제안 할 수 있습니다. 그것은 바로이

처럼 남아있다가 일이 확인 시스템-config.js을 doesnot 경우 당신은 당신의 SRC/된 index.html

<script src="/vendor/redux/dist/redux.js" type="text/javascript"></script> 

에 REDUX 경로를 연결 확인 나 :

을 위해 일 "format_type"`정의를 패키징 :

const packages: any = { 
    'redux':{format: 'cjs',defaultExtension: 'js', main: 'redux.js'} 
}; 
당신이 그것을 실행 :)