Enabling Source Maps

Enabling Source Maps

Source maps allow browsers to access the original code related to some asset (e.g. the Sass code that was compiled to CSS or the TypeScript code that was compiled to JavaScript). Source maps are useful for debugging purposes but unnecessary when executing the application in production.

Encore inlines source maps in the compiled assets only in the development environment, but you can control this behavior with the enableSourceMaps() method:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
// webpack.config.js
// ...

Encore
    // ...

    // this is the default behavior...
    .enableSourceMaps(!Encore.isProduction())
    // ... but you can override it by passing a boolean value
    .enableSourceMaps(true)
;

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.