-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpackio.php
99 lines (85 loc) · 1.96 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
/**
* Webpack styles and scripts hot loader
*
* A class definition that includes functions which provide
* compiled ES6/SASS in production and BrowserSync in development.
*
* @link https://tinypixel.io
* @since 0.0.1
*
* @package voxels
*/
namespace TPC\Voxels;
use Wpackio\Enqueue;
/**
* The Webpack class
*
* Implemented with wpack.io tooling.
*
* @link https://wpack.o
* @since 0.0.1
*
* @package voxels
* @subpackage voxels/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(
'voxels',
'assets',
'0.0.1',
'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();