]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
mention default export in our docs optimize section
authorJohann-S <johann.servoire@gmail.com>
Thu, 1 Oct 2020 07:29:10 +0000 (10:29 +0300)
committerXhmikosR <xhmikosr@gmail.com>
Tue, 20 Oct 2020 08:17:06 +0000 (11:17 +0300)
site/content/docs/5.0/customize/optimize.md

index 358fe86b7320fab93899528c54ed0289987248e0..a554e3c34feaf36e00632e22fe2acb8bb3aa0023 100644 (file)
@@ -24,21 +24,32 @@ For instance, assuming you're using your own JavaScript bundler like Webpack or
 ```js
 // Import just what we need
 
-// import "bootstrap/js/dist/alert";
-// import "bootstrap/js/dist/button";
-// import "bootstrap/js/dist/carousel";
-// import "bootstrap/js/dist/collapse";
-// import "bootstrap/js/dist/dropdown";
-import "bootstrap/js/dist/modal";
-// import "bootstrap/js/dist/popover";
-// import "bootstrap/js/dist/scrollspy";
-// import "bootstrap/js/dist/tab";
-// import "bootstrap/js/dist/toast";
-// import "bootstrap/js/dist/tooltip";
+// import 'bootstrap/js/dist/alert';
+// import 'bootstrap/js/dist/button';
+// import 'bootstrap/js/dist/carousel';
+// import 'bootstrap/js/dist/collapse';
+// import 'bootstrap/js/dist/dropdown';
+import 'bootstrap/js/dist/modal';
+// import 'bootstrap/js/dist/popover';
+// import 'bootstrap/js/dist/scrollspy';
+// import 'bootstrap/js/dist/tab';
+// import 'bootstrap/js/dist/toast';
+// import 'bootstrap/js/dist/tooltip';
 ```
 
 This way, you're not including any JavaScript you don't intend to use for components like buttons, carousels, and tooltips. If you're importing dropdowns, tooltips or popovers, be sure to list the Popper.js dependency in your `package.json` file.
 
+{{< callout info >}}
+### Exports
+
+Files in `bootstrap/js/dist` use the **default export**, so if you want to use one of them you have to do the following:
+
+{{< highlight js >}}
+import Modal from 'bootstrap/js/dist/modal'
+const modal = new Modal(document.getElementById('myModal'))
+{{< /highlight >}}
+{{< /callout >}}
+
 ## Autoprefixer .browserslistrc
 
 Bootstrap depends on Autoprefixer to automatically add browser prefixes to certain CSS properties. Prefixes are dictated by our `.browserslistrc` file, found in the root of the Bootstrap repo. Customizing this list of browsers and recompiling the Sass will automatically remove some CSS from your compiled CSS, if there are vendor prefixes unique to that browser or version.