-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
75 lines (66 loc) · 1.65 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
let mix = require('laravel-mix');
let WebpackObfuscator = require('webpack-obfuscator');
class Obfuscator {
/**
* Options for Javascript Obfuscator.
*
* @ref https://github.com/javascript-obfuscator/javascript-obfuscator#options
* @return {String|Array}
*/
options = {}
/**
* A file names or globs which indicates files to exclude from obfuscation.
*
* @return {String|Array}
*/
exclude = []
/**
* The optional name to be used when called by Mix.
* Defaults to the class name, lowercased.
*
* @return {String|Array}
*/
name() {
return 'obfuscator';
}
/**
* All dependencies that should be installed by Mix.
*
* @return {Array}
*/
dependencies() {
return ['javascript-obfuscator', 'webpack-obfuscator'];
}
/**
* Register the component.
*
* When your component is called, all user parameters
* will be passed to this method.
*
* @param {object} config
* @return {void}
*
*/
register(config) {
let Config = config || {};
this.options = Config.options || this.options;
this.exclude = Config.exclude || this.exclude;
}
/**
* Rules to be merged with the master webpack loaders.
*
* @return {Array|Object}
*/
webpackRules() {
return {
test: /\.js$/,
exclude: this.exclude,
enforce: 'post',
use: {
loader: WebpackObfuscator.loader,
options: this.options
}
}
}
}
mix.extend('obfuscator', new Obfuscator());