Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

Into my project I use the stack Webpack/angular2 (with typescript).

I try to include the .js files of boostrap & jquery but I can't find a simple and well explain way...

I tried succesively to use:

  • imports-loader into webpack.config
  • import "jquery" into vendor-browser.ts
  • require("jquery") into my ts files

I probably miss something...

I'm looking for a generic solution to include a .js file into the "window" object. Files are located into the node_modules folder.

Can someone help me?

Thanks!

share|improve this question
    
have you tried my answer? – MrJSingh Jul 27 at 14:51
    
No, no time right now... – CyrilleGuimezanes Jul 27 at 15:12
up vote 1 down vote accepted

If i understood you then ypu want to add jquery and bootstrap.js in your angular2 project

Here is example how i did.

add a plugin so jquery can be loaded before bootstrap

new webpack.ProvidePlugin({
            $: "jquery",
            jQuery: "jquery"
})

and if you have installed bootstrap and jquery with npm then just import them in your main file

import "bootstrap/dist/js/bootstrap.js";
import "jquery";

now you can test in browser's console by typing $ and it should show you that there is jquery loaded.

share|improve this answer

One solution is this lib (for webpack)

https://github.com/shakacode/bootstrap-loader

Successor to bootstrap-sass-loader. 
Load Bootstrap styles and scripts in your Webpack bundle. 
This loader uses SASS to process CSS styles. 
Bootstrap 3 & 4 are supported.

basic example: https://github.com/shakacode/bootstrap-loader/blob/master/examples/basic

css module example: https://github.com/shakacode/bootstrap-loader/blob/master/examples/css-modules

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.