-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp.js
97 lines (82 loc) · 2.4 KB
/
wp.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const mix = require('laravel-mix');
class WP {
name() {
return 'wp';
}
/**
* All npm dependencies that should be installed by Mix.
*
* @return {Array}
*/
dependencies() {
return ['@babel/preset-env', '@babel/plugin-syntax-dynamic-import', 'exports-loader', 'babel-plugin-dynamic-import-node', '@svgr/webpack'];
}
/**
* Register the component.
*
* When your component is called, all user parameters
* will be passed to this method.
*
* Ex: register(src, output) {}
* Ex: mix.yourPlugin('src/path', 'output/path');
*
* @return {void}
*
*/
register() {
this.autoprefixerConfig = {
overrideBrowserslist : ['last 4 versions', '> 1%'],
grid : 'autoplace' // FOR IE10 add custom or false by mix.options({ autoprefixer:{ grid: false } })
}
}
/**
* Boot the component. This method is triggered after the
* user's webpack.mix.js file has processed.
*/
boot() {
global.Config.processCssUrls = false;
global.Config.autoprefixer = Object.assign(this.autoprefixerConfig, global.Config.autoprefixer);
}
/**
* Override the underlying webpack configuration.
*
* @param {Object} webpackConfig
* @return {void}
*/
webpackConfig(webpackConfig) {
// https://webpack.js.org/guides/build-performance/
webpackConfig.output.pathinfo = false;
// webpackConfig.stats.children = true
// webpack will generate a runtime code for web platform and will use only ES5 features.
webpackConfig.target = ['web', 'es5'];
webpackConfig.externals = {
jquery : 'jQuery', // var $ = require("jquery");
wp : 'wp',
underscore : '_' // var _ = require("underscore");
}
}
/**
* Rules to be merged with the underlying webpack rules.
*
* @return {Array|Object}
*/
webpackRules() {
// Example:
return {
test : /\.svg$/,
use : ['@svgr/webpack', 'url-loader'],
};
}
/**
* Babel config to be merged with Mix's defaults.
*
* @return {Object}
*/
babelConfig() {
return {
plugins : ['dynamic-import-node'],
presets : ["@babel/preset-env"],
};
}
}
mix.extend('wp', new WP());