-
-
Notifications
You must be signed in to change notification settings - Fork 78.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
add webpack to documentation #22423
add webpack to documentation #22423
Conversation
1c41378
to
2817a1b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this, the only question I have is around the placement of this on a separate page—need to think about that a bit more. Also, is there anyone else out there using Webpack that would like to chime in with a review here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few minor optional comments, but otherwise this very similar to my own webpack config.
docs/getting-started/webpack.md
Outdated
{% callout info %} | ||
#### Customization | ||
|
||
To implement the powerful [options](/getting-started/options/) Bootstrap offers, create `_custom.scss` and import it **before** Bootstrap. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you include examples elsewhere, may be nice to do the same here for clarity:
To implement the powerful [options](/getting-started/options/) Bootstrap offers, create a file for variables, such as `_custom.scss`, and import it **before** Bootstrap:
{% highlight scss %}
// theme.scss
$brand-primary: $green;
{% endhighlight %}
{% highlight scss %}
@import "theme.scss";
@import "~bootstrap/scss/bootstrap";
{% endhighlight %}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ajacksified thanks for the feedback! i'll push a new PR later
docs/getting-started/webpack.md
Outdated
group: getting-started | ||
--- | ||
|
||
Use [webpack](https://webpack.js.org/) to bundle Bootstrap into your project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be worth mentioning that this is for webpack v2.
2817a1b
to
4ca4f67
Compare
@ajacksified , i've explicitly mentioned webpack v2 and put more emphasize on custom variables (after all, why even use webpack if you're not planning on customizing?) |
Sorry! Must have missed it.
…On Apr 23, 2017 2:46 PM, "Idan Cohen" ***@***.***> wrote:
@ajacksified <https://github.com/ajacksified> , i've explicitly mentioned
webpack v2 and put more emphasize on custom variables (after all, why even
use webpack if you're not planning on customizing?)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#22423 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAKtm40LIYB96Dt3nUA_35SSKxUPnROkks5ry8avgaJpZM4M7r3k>
.
|
Disregard that, misread the notification email. Looks good to me! |
implementing PR comments implementing PR comments
4ca4f67
to
2f4adf6
Compare
I would suggest using ExtractTextWebpackPlugin in the example, rather than style-loader. With style-loader, the styles are injected into The downside is the slightly added complexity, but the upside is less "magic" around importing styles from JS. |
@samsch , I agree that using ExtractText in many cases would be the best practice. It's actually used it in the demo project I attached to this PR - https://github.com/IdanCo/webpack-modular/tree/bootstrap4 But I'm not convinced it should be a part of the documentation. There are other best-practices (such as using source maps), but adding them to the documentation might imply that they are essential for compiling Bootstrap, even though they are in no way such. Also, i can think of many use cases in which using ExtractText plugin would be counter productive, such as serving dev server or running tests. I hope other resources (blogs, stackoverflow, etc.) will expand and elaborate this basic setup. I know I plan to... |
Just a quick counter argument. I'm actually less concerned with ExtractText
being a best practice, and more interested in having a separate css file to
be more similar to environments which users may be used to.
I do see your point about it seeming to be "required" when it is not.
Perhaps that could be satisfied with an additional sentence or two in the
guide noting that it's optional.
|
Any other feedback before we merge this? (Also, hi @ajacksified! Long time no see! :D) |
My only concern about this PR is, is it the role of BS to show how to integrate BS in any plugins, module bundler etc... ? |
I think so, yes. I'd love more in-depth and helpful guides for using, extending, and contributing to Bootstrap—regardless of the package manager or community. Bootstrap is meant to be accessible to everyone, beginner or seasoned veteran, so I'm a fan :). |
@mdo totally agree. @Johann-S i see your point - Bootstrap can't be held responsible for what other bundlers are doing. But on the other hand, the bundlers also can't commit to how Bootstrap is structured (especially while in alpha). So the outcome is that integrations fall "between the chairs". So taking responsibility for documenting may not be the obvious choice, but it will help bring Bootstrap to more people, and i think that's worth it. Regarding which bundlers should be included, IMO as long as there's a demand for integration documentation, it's worth considering adding. |
That's ok for me 👍 it's just a choice to do |
We are integrating Bootstrap into our web app with Create React App |
@IdanCo can you update your branch ? because now we use Popper instead of Tether |
Done! and congrats on the huge Popper PR @Johann-S , can't wait to give it a try! |
Thank you very much @IdanCo ❤️ |
docs/getting-started/webpack.md
Outdated
$: 'jquery', | ||
jQuery: 'jquery', | ||
'window.jQuery': 'jquery', | ||
Tether: 'tether', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change that by Popper
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On it
docs/getting-started/webpack.md
Outdated
... | ||
{% endhighlight %} | ||
|
||
Bootstrap is dependent on jQuery and Tether, so npm will install them for you if needed. But they must be explicitly provided by webpack. Add the following code to the `plugins` section in your webpack config file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change that by Popper
?
LGTM 👍 The merge is up to @mdo because he said :
|
Changed the webpack configuration to accommodate popper instead of tether. @Johann-S , any reason why bootstrap.js in v4-dev is not yet updated and still dependent on thether? I built it manually to do my tests and find the correct recipe, but I'm curious about the repo build process... BTW, at first glance the new tooltips/popovers/dropdown looks great! EDIT :
no problem, let me know if there's anything i can do to help |
Yes we build manualy And thank you for your feedbacks 👍 |
|
||
Import [Bootstrap's JavaScript](/getting-started/javascript/) by adding this line to your app's entry point (usally `index.js` or `app.js`): | ||
|
||
{% highlight js %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you use the triple back tick?
import 'bootstrap';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we use highlight
everywhere else due to our Jekyll setup.
Thanks y'all! Holler with PRs if y'all have newer/better ideas for setup docs with other tooling. |
@mdo I'd like to point out an issue of compiling the JS with Bootstrap's individual I tested @IdanCo's repo and it looks fine when using the However, if you include the The solution for individual imports is, as suggested in the first link, to include the individual |
Thanks @petrpacas , I'll have a look at it this weekend |
Hi @petrpacas. Personally, I don't use the Provide Plugin but the Expose Loader instead (see my comment here) Maybe you could adapt your import with this loader and see what happen ? |
For those interested, here's my repo with working example of using the individual source files w/ Babel instead: https://github.com/petrpacas/webpack-bootstrap-4-setup |
Hi. I followed the guide and for some reason it kept telling me that Tether was needed. I had to replace Popper with Tether. I've installed Bootstrap with How can I get the dependency to Popper as explained in the documentation? |
@ccalvarez, These instructions refer to the develop branch which replaced Tether with Popper. For version Alpha 6 (which you probably use), You can browse the previous commit, or have a look in the issue discussion. |
@IdanCo I understand, thank you very much! |
Although the documentation is very good, I still found it incomplete regarding the actual NPM packages that need to be installed and interop with other loader(s) who generate source-maps. Here is a Gist that brings it together: https://gist.github.com/chrisalexander55/81f3d5db057fbcbd74d62d488adbca8a Please feel free to use this to update the docs page. |
Summary
Add a guide to the official docs on how to integrate Bootstrap with Webpack.
Motivation
Background
During the past few months i've been integrating bootstrap into several new and existing projects using webpack version 2. This led me to conduct a thorough research and tests on the best practices to achieve this integration. The results of these efforts are in this guide.
Technical
Check out a sample project which implements the steps detailed in this guide -
https://github.com/IdanCo/webpack-modular/tree/bootstrap4