-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
68 lines (60 loc) · 1.27 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
const mix = require('laravel-mix');
/**
* Lodash Laravel Mix Plugin
*
* @see https://github.com/lodash/lodash-webpack-plugin
*/
class LodashMixPlugin {
/**
* Register the component.
*
* @param {*} ...params
* @return {void}
*
*/
register(config = {}) {
this.config = config;
}
/**
* All dependencies that should be installed by Mix.
*
* @return {Array}
*/
dependencies() {
return [
'lodash-webpack-plugin',
'babel-plugin-lodash'
];
}
/**
* Plugins to be merged with the master webpack config.
*
* @return {Array|Object}
*/
webpackPlugins() {
try {
var LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
return new LodashModuleReplacementPlugin(this.config);
} catch (e) {
console.log('\n\tFinished. Please run Mix again.\n');
}
}
/**
* Babel config to be merged with Mix's defaults.
*
* @return {Object}
*/
babelConfig() {
return {
plugins: ['lodash']
};
}
}
/**
* Attatch API to Laravel Mix
*/
mix.extend('lodash', new LodashMixPlugin);
/**
* Export Module
*/
module.exports = LodashMixPlugin;