Skip to content

Instantly share code, notes, and snippets.

@rebelweb
Created December 8, 2017 13:22
Show Gist options
  • Select an option

  • Save rebelweb/c2c8e08ab57daecbdc8286b9e18ed2fe to your computer and use it in GitHub Desktop.

Select an option

Save rebelweb/c2c8e08ab57daecbdc8286b9e18ed2fe to your computer and use it in GitHub Desktop.
Webpacker / Bootstrap Config
<%# /app/views/layouts/application.html.erb %>
<!DOCTYPE html>
<html>
<head>
<title>RyancondronPhotography</title>
<%= csrf_meta_tags %>
<%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= yield %>
</body>
</html>
// app/javscripts/packs/application.js
console.log('Hello World from Webpacker')
// import javascript dependencies
import 'jquery'
import 'popper.js'
import 'bootstrap'
// import stylesheets
import '../application'
// app/javascripts/application.scss
// Bootstrap
@import 'node_modules/bootstrap/scss/bootstrap';
// config/webpack/development.js
const environment = require('./environment')
module.exports = environment
// config/webpack/environment.js
const { environment } = require('@rails/webpacker')
const webpack = require('webpack')
environment.plugins.set('Provide', new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
jquery: 'jquery',
Popper: 'popper.js'
})
)
const config = environment.toWebpackConfig()
config.resolve.alias = {
jquery: 'jquery/src/jquery',
'popper.js': 'popper.js/dist/umd/popper.js'
}
module.exports = config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment