Menu icon Foundation
Include jQuery plugin inside Foundation using import and Webpack

I'm trying to import a jQuery plugin using import in app.js file on Zurb Foundation. I know I can include js file using "traditional" way but I want to take advantage of Webpack which is included in Zurb Foundation config.

My first idea was to use

import './lib/validate.rut.min';

and then

$(document).ready(function () {

$('#username-140').Rut({
    format_on: 'keyup',
    on_error: function () {
        alert('Please user a valid RUT.');
        $('#username-140').attr('value', '').focus();
    }
});

});

I get then

app.js:14497 Uncaught TypeError: (0 , _jquery2.default)(...).Rut is not a function
at HTMLDocument.<anonymous> (app.js:14497)
at mightThrow (app.js:3508)
at process (app.js:3563)

I'm lost. I don't know what to do. Please help.

 

 

 

webpackjavascriptesBabeles2015

I'm trying to import a jQuery plugin using import in app.js file on Zurb Foundation. I know I can include js file using "traditional" way but I want to take advantage of Webpack which is included in Zurb Foundation config.

My first idea was to use

import './lib/validate.rut.min';

and then

$(document).ready(function () {

$('#username-140').Rut({
    format_on: 'keyup',
    on_error: function () {
        alert('Please user a valid RUT.');
        $('#username-140').attr('value', '').focus();
    }
});

});

I get then

app.js:14497 Uncaught TypeError: (0 , _jquery2.default)(...).Rut is not a function
at HTMLDocument.<anonymous> (app.js:14497)
at mightThrow (app.js:3508)
at process (app.js:3563)

I'm lost. I don't know what to do. Please help.

 

 

 

Dustin almost 2 years ago

Same problem here. Did you come up with a solution?

Deryck Oñate almost 2 years ago

No. I just removed Webpack from my workflow. :(