M
M
mskr2019-04-01 00:51:05
webpack
mskr, 2019-04-01 00:51:05

How to exclude a function from minification?

Good afternoon!
In laravel mix, when compiling for production, the .js() module automatically minifies the file and mangles function names.
Is it possible to disable this name distortion globally or for certain functions?
I found this setting in the babel doc, but it doesn't work

{
  "plugins": [
    ["minify-mangle-names", { "exclude": { "foo": true, "bar": true} }]
  ]
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2019-04-01
@Sanasol

Minification does not distort what is defined in the global scope.
And the fact that you shouldn’t really need it inside, you still won’t be able to call from the outside.
For everything else, there are other solutions.
So you are doing something wrong in the first place.
In general, I have never seen that it was possible to exclude specific functions from minification somewhere, only entire files.
If we are talking about the latest version of laravel mix/webpack, then look here https://github.com/webpack-contrib/terser-webpack-...
Since babel is not generally responsible for minification there. (babel is generally about something else if anything)

M
mskr, 2019-04-03
@mskr

In general, I did this: in src / js I started two daddies: minify and normal - I threw files into the latter (in which I placed the necessary functions) that do not require webpack.mix.js
minification

.js('src/js/minify/*.js', 'js/scripts.compiled.js')
.combine(['js/scripts.compiled.js', 'src/js/normal/*.js'], 'js/scripts.js')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question