jQuery Version of autocomplete.js via Webpack(er)

I’m trying to install the jQuery version of autocomplete.js via Webpacker into my Rails application. I’ve tried many combinations of plugins, aliases, and importing with no luck.

Here are (what I think) the relevant bits of my configuration. What is the correct/recommended way to get this working?


const { environment } = require("@rails/webpacker")
const webpack = require("webpack")
const coffee = require("./loaders/coffee")

  new webpack.ProvidePlugin({
    $: "jquery",
    jQuery: "jquery",
    algoliasearch: "algoliasearch",
    autocomplete: "autocomplete",
    "sticky-kit": "sticky-kit",
    "sticky-table-headers": "sticky-table-headers",

const config = environment.toWebpackConfig()

config.resolve.alias = {
  jquery: "jquery/src/jquery",
  autocomplete: "autocomplete.js/index_jquery",
  "sticky-kit": "sticky-kit/dist/sticky-kit",
  "sticky-table-headers": "sticky-table-headers/js/jquery.stickytableheaders",

environment.loaders.append("coffee", coffee)

module.exports = environment


/* eslint no-console:0 */

// IE 11 polyfills
import "core-js"
import "element-closest"
import "classlist-polyfill"

// Stimulus
import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"

const application = Application.start()
const context = require.context("controllers", true, /.js$/)

// vendor
import {} from "jquery-ujs"
import {} from "sticky-kit"
window.Cookies = require("js-cookie")

Hi @eric2, I’ve answer to your question on GitHub.

Let me know how it goes!

That worked perfectly, thank you @samuel.vaillant!