-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
wpackio.php
99 lines (85 loc) · 2.02 KB
/
wpackio.php
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
98
99
<?php
/**
* The file that defines the webpack integration with WP
*
* A class definition that includes functions which provide
* compiled ES6/SASS in production and BrowserSync in development.
*
* @link https://tinypixel.io
* @since 1.0.0
*
* @package every-action
* @subpackage every-action/wpackio
*/
use Wpackio\Enqueue;
/**
* The Webpack class
*
* Implemented with wpack.io tooling.
*
* @link https://wpack.o
* @since 1.0.0
*
* @package every-action
* @subpackage every-action/wpackio
* @author Tiny Pixel Collective, Kelly Mears <[email protected]>
*/
class Webpack {
/**
* Webpack.io Instance
*
* @link https://wpack.io
*/
public $webpack;
/**
* Webpackio needs to do its work
* in the plugin's initial construct()
*
* @link https://wpack.io
*/
public function __construct() {
$this->webpack = new \WPackio\Enqueue(
'every-action',
'scripts',
'1.0.0',
'plugin',
__FILE__
);
/**
* Call member functions to enqueue webpack
* generated assets
*
* @link https://wpack.io
*/
add_action( 'admin_enqueue_scripts', [ $this, 'webpack_assets_editor' ] );
add_action( 'wp_enqueue_scripts', [ $this, 'webpack_assets_public' ] );
}
/**
* Enqueue administrative scripts and styles
*/
public function webpack_assets_editor() {
$this->webpack->enqueue( 'blocks', 'editor', [
'js' => true,
'css' => true,
'js_dep' => [
'wp-blocks',
'wp-element',
'wp-components',
'wp-editor',
'lodash',
'wp-i18n',
'wp-hooks',
'wp-data'],
'css_dep' => [],
'in_footer' => true,
'media' => 'all',
]);
}
/**
* Enqueue public facing scripts and styles
*/
public function webpack_assets_public() {
$this->webpack->enqueue( 'blocks', 'public', [] );
}
}
new webpack();