Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Import bootstrap4 #367

Closed
felek000 opened this issue Dec 30, 2016 · 3 comments
Closed

Import bootstrap4 #367

felek000 opened this issue Dec 30, 2016 · 3 comments

Comments

@felek000
Copy link

Hello i install bootstrap 4 via npm so source files are in node modules.
I import scss files and works fine.

Now i want to add js files.
In modules i create folder b4.js and import jquery after that i import modules from bootstrap. Iget folowing error that jQuery is not defind in import file.

code

import jQuery from '../../../node_modules/jquery/dist/jquery';
import '../../../node_modules/bootstrap/js/dist/alert'

I also import file in app.js

My question is how can i import bootstrap js to project when i add it like simple cdn file it works fine.

@cesasol
Copy link

cesasol commented Jan 3, 2017

Prefer npm over bower, for example for bootstrap 4 you can use:

yarn add [email protected]

// jQuery
var $ = require('jquery');
global.jQuery = $;
// All of bootstrap
require('bootstrap');
// only alert
require('bootstrap/js/src/alert.js');

Webpack in this way resolves js from src/javascripts and from node_modules

@jbielick
Copy link

jbielick commented Jan 4, 2017

Bootstrap4 uses an in-house dependency system, so Webpack won't be able to resolve any dependencies in the bootstrap javascript modules. You may find this readme helpful. Without the Provide plugin definitions like that example has, none of the bootstrap javascript works correctly.

Here's the github issue where it's explained. You'll also need the exports-loader installed!

@cannap
Copy link

cannap commented Feb 10, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants