Laravel-mix: Avoid loading JavaScript maps

Created on 14 Sep 2017  路  4Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 1.4.3
  • Node Version: 8.4.0
  • NPM Version: 5.4.1
  • OS: macOS 10.12.6

Description:

I'm importing Popper.js like this:

import Popper from 'popper.js';
window.Popper = Popper;

And it works perfectly, but in my Browser console I see the following error message:

https://example.com/js/popper.js.map: Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404)

Is there any way to strip all source map references in JavaScript files?

Most helpful comment

It's actually Safari that tries to download it, not Chrome.

Is there an easy way to strip comments containing sourceMappingURL with Mix?

All 4 comments

I don't think it is Laravel mix fault.
Popper.js npm package comes with sourcemap files, (screenshot)
screenshot from 2017-09-17 10-01-41

The umd/popper.js file has a link to these sourcemap files, see next source code
https://unpkg.com/[email protected]/dist/umd/popper.js
When you open up devtools, chrome tries to download these linked map files but could not, because these files are in node_modules (behind your public folder).

FYI: Chrome will not download source map file unless you open dev tools.

Popper.js provides the maps, so it's not its fault if they don't get served by Laravel

It's actually Safari that tries to download it, not Chrome.

Is there an easy way to strip comments containing sourceMappingURL with Mix?

The following code solved it for me:

import { Popper } from 'popper.js'
window.Popper = Popper

I have added {} around Popper

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wendt88 picture wendt88  路  3Comments

sdebacker picture sdebacker  路  3Comments

hasnatbabur picture hasnatbabur  路  3Comments

Cheddam picture Cheddam  路  3Comments

mementoneli picture mementoneli  路  3Comments