Roots Discourse

Sage9 and MixItUp


#1

Hi all!
I`ll trying to install the JS plugin for filtering MixItUp

I added this package via webpack (yarn add mixitup), and add to the main.js
import mixitup from 'mixitup';

When I init plugin with the code in common.js route:
var mixer = mixitup(containerEl);
console.log(mixitup);
i got the error:
error 'mixitup' is defined but never used no-unused-vars

But plugin works, when i run the init code from ‘main.js’ directly, or add import mixitup from 'mixitup'; to common.js.

Anybody can help how to init this plugin corectly?


#2

In routes/common.js, you should be able to just add:

import mixitup from 'mixitup';

export default {
  init() {
    var mixer = mixitup('.container'); // or whatever you want

    // then make sure to use the variable or else eslint will yell at you.
  },
  finalize() {
  },
};

Does this work?


#3

Yeah, works fine! Thank you!

However, is it ok to use import in the common.js file?

Before that, I was thought that it was only use in main.js