Skip to content

Instantly share code, notes, and snippets.

@guillaumecabanel
Last active May 3, 2018 09:00
Show Gist options
  • Save guillaumecabanel/703d53b7cddc0f36f8bd0f0242d4e257 to your computer and use it in GitHub Desktop.
Save guillaumecabanel/703d53b7cddc0f36f8bd0f0242d4e257 to your computer and use it in GitHub Desktop.
/ app/views/layouts/application.html.slim
doctype html
html
head
meta charset="UTF-8"
meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"
title title
= favicon_link_tag 'favicon.png'
= csrf_meta_tags
= action_cable_meta_tag
= stylesheet_link_tag 'application', media: 'all'
/ Uncomment the next line if you import CSS in app/javascript/packs/application.js
= stylesheet_pack_tag 'application'
body
= yield
= javascript_include_tag 'application'
= javascript_pack_tag 'application'
// app/javascript/packs/application.js
import "bootstrap";
import "../plugins/flatpickr";
// config/webpack/environment.js
const { environment } = require('@rails/webpacker')
// Bootstrap 3 has a dependency over jQuery:
const webpack = require('webpack')
environment.plugins.prepend('Provide',
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
})
)
module.exports = environment
// app/javascript/plugins/flatpickr.js
import flatpickr from "flatpickr";
import "flatpickr/dist/flatpickr.min.css";
flatpickr('.datepicker', {});
{
"name": "name",
"private": true,
"dependencies": {
"@rails/webpacker": "3.4",
"bootstrap": "3",
"flatpickr": "^4.4.4",
"jquery": "^3.3.1"
},
"devDependencies": {
"webpack-dev-server": "2.11.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment