2017-04-06 4 views
0

Bootstrap、jQuery、ng2-oauth2、Wijmoなどのサードパーティのライブラリを使用して小さなプロジェクトを作成しました。webpackを使用してプロジェクトをバンドルすることに決めました。誰でも私のwebpackの実装にそれらのサードパーティのライブラリを含める方法を教えてもらえますか?サードパーティのライブラリを含む角2のWebpackを含む

// Angular 

import '@angular/platform-browser'; 
import '@angular/platform-browser-dynamic'; 
import '@angular/core'; 
import '@angular/common'; 
import '@angular/http'; 
import '@angular/router'; 
// RxJS 
import 'rxjs'; 
// Other vendors for example jQuery, Lodash or Bootstrap 
// You can import js, ts, css, sass, ... 
import 'bootstrap/dist/css/bootstrap.min.css'; 
import 'bootstrap-social/bootstrap-social.css'; 
import 'font-awesome/css/font-awesome.min.css'; 
import 'angular2-toaster/toaster.css'; 


import 'jquery/dist/jquery.min.js'; 
import 'bootstrap/dist/js/bootstrap.min.js';` 

これは、インポートするための正しい方法です:

私はvendor.tsに、このように輸入してきましたか?私はこのようにjQueryを使用している

error page

:jQueryの動的なスクリプトに私のフッターセクションを整列させるために使用される

import { Injectable } from '@angular/core'; 
declare var jQuery: any; 

@Injectable() 
export class FooterService { 

    //Get getFooterAlign Service 
    getFooterAlign(): any { 
     var getHeight = jQuery(window).height() - 225; 
     if (jQuery(".body-container").height() < getHeight) { 
      jQuery(".logInWrapper, .contentWrapper, .signupWrapper").css("height", jQuery(window).height() - 232); 
      jQuery(window).resize(function() { 
       jQuery(".logInWrapper, .contentWrapper").css("height", jQuery(window).height() - 225); 
      }); 
     } 
     else { 
      jQuery(".logInWrapper, .contentWrapper, .signupWrapper").css("height", jQuery(".body-container").height()); 
      jQuery(window).resize(function() { 
       jQuery(".logInWrapper, .contentWrapper").css("height", jQuery(".body-container").height()); 
      }); 
     } 
    } 

} 

それは、このエラーを示します。

私のコードで間違いがありましたか?ブートストラップおよびその他のサードパーティのライブラリのための

+0

はなぜHTTPを試していない:// localhostを:9090 /#/すべてのあなたのための、入門ブートストラップが必要ですか? –

答えて

0
after researching i found some solution for Jquery include below code in webpack.config.js file is working fine for me: 

    module.exports = { 
     resolve: { 
      extensions: ['.ts', '.js'], 
      alias: { 
       jquery: "jquery/src/jquery" 
      } 
     } 

---------- 

    plugins: [ 
      new webpack.ProvidePlugin({ 
       jQuery: 'jquery', 
       $: 'jquery', 
       jquery: 'jquery' 
      }) 
     ] 

uが直接vendor.tsファイルにインポートすることができます:

import 'bootstrap/dist/css/bootstrap.min.css'; 
import 'bootstrap-social/bootstrap-social.css'; 
import 'font-awesome/css/font-awesome.min.css'; 
import 'angular2-toaster/toaster.css'; 

import 'bootstrap/dist/js/bootstrap.min.js'; 
import 'angular2-jwt/angular2-jwt.js'; 
import '@ng-idle/core/bundles/core.umd.js'; 
import 'ng2-recaptcha'; 
import 'ng2-ckeditor'; 
import 'angular2-toaster/bundles/angular2-toaster.umd.js'; 
import 'ng2-bootstrap'; 
import 'crypto-js/crypto-js.js'; 
関連する問題