Alpine js not working in production mode

Hello dear community,

I implemented alpine.js in my project, it works perfectly in dev mode, but not in production mode. In production mode, nothing happens, I cannot interact with elements. And I don’t know why. Minification? something else?

My code for now:

import {domReady} from '@roots/sage/client'
import Alpine from 'alpinejs'

import * as Menu from './components/menu.js'

/*
/**
 * app.main
 */
const main = async (err) => {
  if (err) {
    // handle hmr errors
    console.error(err)
  }

  Menu.init()

  window.Alpine = Alpine
  Alpine.start()

  // application code
};

/**
 * Initialize
 *
 * @see https://webpack.js.org/api/hot-module-replacement
 */
domReady(main);
import.meta.webpackHot?.accept(main);

And my test:

<div x-data="{ title: 'Start Here' }">
    <h1 x-text="title"></h1>
</div>

Thank you in advance,

Hi,

what is your acorn version ?

Hello Aksld,

Well, I don’t really know which one you need so here is what I have:

├─┬ @roots/bud-tailwindcss@5.8.7
│ └─┬ tailwindcss@3.0.24
│   └─┬ detective@5.2.0
│     └─┬ acorn-node@1.8.2
│       └── acorn@7.4.1
└─┬ @roots/bud@5.8.7
  ├─┬ html-webpack-plugin@5.5.0
  │ └─┬ html-minifier-terser@6.1.0
  │   └─┬ terser@5.14.2
  │     └── acorn@8.7.1 deduped
  └─┬ webpack@5.72.1
    ├─┬ acorn-import-assertions@1.8.0
    │ └── acorn@8.7.1 deduped
    └── acorn@8.7.1

and

"require": {
    "php": "^7.4|^8.0",
    "roots/acorn": "^2.1"
  },

Thank you in advance,

I have no solution for you, just want to say that I use Alpine in the same way and it works just fine. No errors in console?
(Edit I use Acorn as plugin by the way, so that’s a difference)

Hello! thank you, what is your acorn version?

For that website I’m on acorn 2.03

Have you looked at the built JS file after running the production build? Is Alpine there? Do you see anything in the browser console when loading the site after a production build?

I asked for the acorn version because the v.2.1.1 fix javascript enqueue problem.

Hello, I updated Acorn from v2.1 to v2.1.2 and it’s working now.

Thanks guys for your answers.