kittencup / angular2-ama-cn

angular2 随便问
691 stars 101 forks source link

如何通过system-config.ts把 前端库 bootstrap植入到项目中 #171

Closed ghost closed 8 years ago

ghost commented 8 years ago

bootstrap:http://v4-alpha.getbootstrap.com/

之前我是直接在源码里 添加如下代码:

<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
  <script src="node_modules/jquery/dist/jquery.min.js"></script>
  <script src="node_modules/tether/dist/js/tether.min.js"></script><!-- bootstrap need-->
  <link rel="stylesheet" href="node_modules/tether/dist/css/tether.min.css"> <!-- bootstrap need-->
  <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>

但是,现在我换了 https://github.com/angular/angular-cli 来管理打包项目

所以我想把通过system-config.ts来 把bootstrap添加到项目中

通过修改 angular-cli-build.js,可以让angular-cli 编译的时候把bootstrap打包到dist目录里,但是我的项目并没有引入bootstrap

// angular-cli-build.js
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/**/*.+(js|js.map)',
      'rxjs/**/*.+(js|js.map)',
      '@angular/**/*.+(js|js.map)',
      'bootstrap/**/*.+(js|js.map|css|css.map)'
    ]
  });
};

请问除了,直接在 index.html里面添加 link 和script标签来引入js和css代码之外, 能不能直接通过修改配置文件,让他可以包含bootstrap

ghost commented 8 years ago

最后我还是在页面里 用 script 和link 标签引入的