laravel-mix injects unknown Javascript into my compiled JS

Created on 21 Feb 2017  路  5Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 0.8.1
  • Node Version (node -v): 7.5.0
  • NPM Version (npm -v): 4.1.0
  • OS: Windows 10

Description:

Whenever I compile my JS with laravel-mix, the combined file app.js contains some webpack-JavaScript, that stops my JS from working in the browser. The code looks somewhat like this:

/******/ (function(modules) { // webpackBootstrap
/******/    // The module cache
/******/    var installedModules = {};

/******/    // The require function
/******/    function __webpack_require__(moduleId) {
etc...

/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(0)))

/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {

/* WEBPACK VAR INJECTION */(function($, jQuery) { ...}

Steps To Reproduce:

webpack.mix.js:

mix.js([
    'resources/assets/js/jquery.ajaxsetup.js',
    'resources/assets/js/jquery.document.ready.js',
    'resources/assets/js/jquery.helpers.js',
    'resources/assets/js/jquery.glossarium.vocab.js',
    'resources/assets/js/jquery.glossarium.lektionen.js',
    'resources/assets/js/jquery.glossarium.sachfelder.js',
    'resources/assets/js/jquery.notifications.js',
    'resources/assets/js/jquery.modal.js'], 'public/js/app.js')

npm run dev

Most helpful comment

It looks like you mostly want to concatenate files? If so, use mix.combine() instead.

All 5 comments

It looks like you mostly want to concatenate files? If so, use mix.combine() instead.

Thanks, you helped me a lot

But this doesn't compile ECMA-script.
So what you could do is.

mix.sass('resources/assets/sass/app.scss', '../resources/assets/css') .js([ 'resources/assets/js/main.js', 'resources/assets/js/compiled/angular.js'], 'public/js/all.js') .sass('resources/assets/materialize-src/sass/materialize.scss', '../resources/assets/css') .extract(['jquery']);

=> Extract the module.
check your package.json to see which modules are compiled.

for more info:
https://laravel.com/docs/5.4/mix#vendor-extraction

How to disable this ? I don't want concatenate files...

Use mix.script()

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nezaboravi picture nezaboravi  路  3Comments

wendt88 picture wendt88  路  3Comments

hasnatbabur picture hasnatbabur  路  3Comments

jpriceonline picture jpriceonline  路  3Comments

Cheddam picture Cheddam  路  3Comments