-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to include Twitter Bootstrap 3 using webpack #696
Comments
Maybe you are looking for ng2-bootstrap Generally to load jQuery in your project do
That's it, all external libraries works the same way, in some cases when the library doesn't include index.js in their root directory, then you will need to locate it the way you are doing like |
@MurhafSousli Thanks for the response. I have looked at ng-bootstrap, and it seems great. However, I have a restriction which requires me to use standard bootstrap 3. As for jQuery, I have added it into the project using |
I just tested it now.
Step 2: Import them in vendor.ts:
Step 3: Go to wepback.common.js in config directory and add this inside plugin section:
This will let bootstrap to find jquery Step 4: Import bootstrap css, you can do that by importing it in the head of your index.html or from your app.css, I used the second way.
The reason I didn't import it from node_modules folder that It won't load the fonts, however you can fix this by overriding the fonts imports in app.css After you do these steps you will probably get this error:
|
@MurhafSousli Thank you for the help. |
@MurhafSousli Is there any way to include bootstrap css without using I tried using relative path: @import url('/node_modules/bootstrap/dist/css/bootstrap.css'); but it gives me HTTP 404:
|
@gearlles You are getting the 404 because |
@shahzad-0 Thanks. But I think it's not a good idea, it's harder to maintain. Suppose I want to upgrade bootstrap version in the future, not everyone in the project would know that apart from Note that this problem exists in the @MurhafSousli solution. Both |
@gearlles Yes, I agree. That's what I was trying to find out when I created the issue. But since importing the css into Please post a solution here when you find one. |
@shahzad-0 I will. Would you mind reopening your issue or I should create another issue to discuss this? |
@shahzad-0 I don't know your requirements, but I got Bootstrap 3 (sass) working based on #215. Please check if it works for you too. 1. Install dependencies
Note: I'm not sure if all dependencies are indeed necessary. I used dependencies from #215 and added others to get it working for Bootstrap 3. 2. Configure WebpackEdit To add loaders, edit
|
@gearlles I have a limitation of using |
@gearlles to import the style from from component:
or from stylesheet
To get bootstrap glyphicons when importing it locally, the only workaround I found is to copy the fonts folder into assets and then override the fonts from your stylesheet
|
I did as you described, but still have Module parse error for those font files. How are you doing the import in your own scss file exactly? |
@harunurhan I didn't import anything in my .scss. The second loader Please try |
@gearlles that doesn't work neither. I also tried using other loaders like file-loader but no luck 😢 Stack trace: |
Try this : {
test: /\.(woff2?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
loader: "file?name=fonts/[name].[ext]"
} |
@phiphou |
@harunurhan Did you correctly set up the Here is what I use for Foundation, should be a solution for BootStrap too : sassLoader: {
includePaths: [path.resolve(__dirname, "../../node_modules/foundation-sites/scss")]
} |
@phiphou |
@harunurhan I just tried using fonts and they work. Please check https://github.com/gearlles/angular2-webpack-starter Looking at your stacktrace, your edited |
@gearlles your solution worked. No issues. i've tried many others floating around the internet and this is the only one that worked. This worked using the default fresh install of this repo. |
@gearlles can you explain how to make Bootstrap 3 (without sass) here ? |
@niyazhussain I'm afraid I can't. At that time, I just tried Sass. |
this one works: |
Cannot get it to work with Release 5.1.1 of angular2-webpack-starter. I tried @gearlles solution, but I am always getting errors of unmet peer dependencies:
Building results in errors, too:
Do I miss something? |
@oli-ver i think you can find answer here. This instruction for bootstrap 4 but you can make same for resolve your problem #1156 (comment) |
@gearlles , |
all the steps described here work for me, except:
can someone give me a hand on how to add loaders to https://github.com/AngularClass/angular2-webpack-starter/blob/master/config/webpack.common.js as there is not even a guess I need different syntax for this? or something completely different? I'm lost. |
@gearlles's post is really useful, it works for me. |
Hi guys, Just to share what I've done recently on the Angular 5 Starter:
in your styles.scss / main.scss (whatever), add Hope this helps! |
If you are using
|
Hi,
I have taken a look at #214 & #215, but these don't really explain how to setup bootstrap 3. I also tried going on the slack chat page, but that seems to be broken.
I have installed the npm packages for jquery & bootstrap, and then added imports into
vendor.ts
, but I still don't have any bootstrap styling showing up on the browser.I also tried adding another entry within
webpack.common.js
, but that didn't help either.Any help would be much appreciated, thanks.
The text was updated successfully, but these errors were encountered: