Skip to content

Instantly share code, notes, and snippets.

@Ryan-McBride
Last active December 11, 2019 18:02
Show Gist options
  • Save Ryan-McBride/92a3a4f52b4cad55059faa8149f227fb to your computer and use it in GitHub Desktop.
Save Ryan-McBride/92a3a4f52b4cad55059faa8149f227fb to your computer and use it in GitHub Desktop.
npm install bootstrap popper.js jquery webpack
to layout.jsx (or whatever component will for sure be on every page) import 'bootstrap'
in gatsby-node.js:
const webpack = require('webpack');
exports.onCreateWebpackConfig = ({ actions, stage, loaders }) => {
const config = {
plugins: [
new webpack.ProvidePlugin({
jQuery: 'jquery',
$: 'jquery',
jquery: 'jquery',
}),
],
};
if (stage === 'build-html') {
config.module = {
rules: [
{
test: require.resolve('bootstrap'),
use: loaders.null(),
},
{
test: require.resolve('jquery'),
use: loaders.null(),
},
],
};
}
actions.setWebpackConfig(config);
};
Add the following to the Helmet
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossOrigin="anonymous" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment