mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-19 16:54:24 +01:00
Use UMD and fix build to properly load deps (#24783)
This commit is contained in:
parent
ffc5965f2c
commit
7fd265034c
@ -37,7 +37,7 @@ module.exports = {
|
|||||||
input: path.resolve(__dirname, '../js/src/index.js'),
|
input: path.resolve(__dirname, '../js/src/index.js'),
|
||||||
output: {
|
output: {
|
||||||
file: path.resolve(__dirname, `../dist/js/${fileDest}`),
|
file: path.resolve(__dirname, `../dist/js/${fileDest}`),
|
||||||
format: 'iife'
|
format: 'umd'
|
||||||
},
|
},
|
||||||
name: 'bootstrap',
|
name: 'bootstrap',
|
||||||
external,
|
external,
|
||||||
|
@ -26,25 +26,9 @@ import 'bootstrap/js/dist/dropdown';
|
|||||||
...
|
...
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
Bootstrap is dependent on [jQuery](https://jquery.com/) and [Popper](https://popper.js.org/), 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:
|
Bootstrap is dependent on [jQuery](https://jquery.com/) and [Popper](https://popper.js.org/),
|
||||||
|
these are defined as `peerDependencies`, this means that you will have to make sure to add both of them
|
||||||
{% highlight js %}
|
to your `package.json` using `npm --save jquery popper.js`.
|
||||||
// don't forget to import webpack (using import or require) to use webpack.ProvidePlugin
|
|
||||||
plugins: [
|
|
||||||
...
|
|
||||||
new webpack.ProvidePlugin({
|
|
||||||
$: 'jquery',
|
|
||||||
jQuery: 'jquery',
|
|
||||||
'window.jQuery': 'jquery',
|
|
||||||
Popper: ['popper.js', 'default'],
|
|
||||||
// In case you imported plugins individually, you must also require them here:
|
|
||||||
Util: "exports-loader?Util!bootstrap/js/dist/util",
|
|
||||||
Dropdown: "exports-loader?Dropdown!bootstrap/js/dist/dropdown",
|
|
||||||
...
|
|
||||||
})
|
|
||||||
...
|
|
||||||
]
|
|
||||||
{% endhighlight %}
|
|
||||||
|
|
||||||
{% callout warning %}
|
{% callout warning %}
|
||||||
Notice that if you chose to **import plugins individually**, you must also install [exports-loader](https://github.com/webpack-contrib/exports-loader)
|
Notice that if you chose to **import plugins individually**, you must also install [exports-loader](https://github.com/webpack-contrib/exports-loader)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user