jQuery

Public
Add jQuery to your Rails app using Webpacker with this app template.
Icons/chart bar
Used 17 times
Created by
T Tadeu Granemann

Usage

Run this command in your Rails app directory in the terminal:

rails app:template LOCATION="https://railsbytes.com/script/XLEsv4"
Template Source

Review the code before running this template on your machine.

run("yarn add jquery")

inject_into_file 'config/webpack/environment.js', after: "const { environment } = require('@rails/webpacker')\n" do <<~EOF
const webpack = require("webpack");
environment.plugins.prepend(
  "Provide",
  new webpack.ProvidePlugin({
    $: "jquery/src/jquery",
    jQuery: "jquery/src/jquery",
  })
);
  EOF
end
Comments

Sign up or Login to leave a comment.