avoid generating new sourcemaps for files not changed in laravel-mix

Viewed 197

Every time when I run npm run prod, all the *.js.map files are modified. Is there a way to avoid this?

It is annoying that I have to checkout unrelated sourcemaps files beforegit commit every time. If I just add them to the repo, the repo gets larger and larger.

Thanks in advance. :D

(ps: We have to put the compiled files in git repo. It is not up to me.)

Here is my webpack.mix.js file.

const mix = require('laravel-mix');
const glob = require('glob');

const userScripts = glob.sync('resources/assets/user/js/**/[^_]*.js');

if (process.env.NODE_ENV === 'production') {
    mix.sourceMaps();
}

userScripts.forEach(filename => {

    const filenameAry = filename.substr('resources/assets/user/js/'.length).split('/');
    const dist = 'public/assets/user/js/' + filenameAry.splice(0, filenameAry.length - 1).join('/');

    mix.js(filename, dist).version();
});
0 Answers
Related