Feb 18, 2022
0
Level 1
$.extend is not a function while mixing js
I am trying to mix js files. I encountered several errors.
After research and many tests, my webpack.mix.js file is
const mix = require('laravel-mix');
require('laravel-mix-sri');
mix.webpackConfig(
webpack => {
return {
externals: {
jquery: "'jquery'",
}
}
});
mix.js('public/js/commun/jquery.js', 'public/js/commun/jquery.js')
.js('public/js/commun/jquery.validate.js', 'public/js/commun/jquery.validate.js');
No more errors when compiling.
But in browser I have multiple $.extend is not a function.
The jquery.validate.js file begins, after mix, like this
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./public/js/commun/jquery.validate.js":
/*!*********************************************!*\
!*** ./public/js/commun/jquery.validate.js ***!
\*********************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
/*!
* jQuery Validation Plugin v1.19.2
*
* https://jqueryvalidation.org/
*
* Copyright (c) 2020 Jörn Zaefferer
* Released under the MIT license
*/
(function (factory) {
if (true) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! jquery */ "jquery")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
})(function ($) {
$.extend($.fn, { <== here is the error
I do not know what to do
Please or to participate in this conversation.