@@ -15,11 +15,18 @@ import { WebpackPluginConfig, WebpackPluginEntryPoint } from './Config';
15
15
16
16
const BASE_PORT = 3000 ;
17
17
18
- export class WebpackPlugin extends PluginBase < WebpackPluginConfig > {
18
+ export default class WebpackPlugin extends PluginBase < WebpackPluginConfig > {
19
19
name = 'webpack' ;
20
20
private isProd = false ;
21
21
private baseDir ! : string ;
22
22
23
+ constructor ( c : WebpackPluginConfig ) {
24
+ super ( c ) ;
25
+
26
+ this . startLogic = this . startLogic . bind ( this ) ;
27
+ this . getHook = this . getHook . bind ( this ) ;
28
+ }
29
+
23
30
private resolveConfig = ( config : Configuration | string ) => {
24
31
if ( typeof config === 'string' ) return require ( config ) as Configuration ;
25
32
return config ;
@@ -41,7 +48,7 @@ export class WebpackPlugin extends PluginBase<WebpackPluginConfig> {
41
48
return null ;
42
49
}
43
50
44
- async getMainConfig ( ) {
51
+ getMainConfig = async ( ) => {
45
52
const mainConfig = this . resolveConfig ( this . config . mainConfig ) ;
46
53
47
54
if ( ! mainConfig . entry ) {
@@ -75,7 +82,7 @@ export class WebpackPlugin extends PluginBase<WebpackPluginConfig> {
75
82
} , mainConfig || { } ) ;
76
83
}
77
84
78
- async getRendererConfig ( entryPoint : WebpackPluginEntryPoint ) {
85
+ getRendererConfig = async ( entryPoint : WebpackPluginEntryPoint ) => {
79
86
const rendererConfig = this . resolveConfig ( this . config . renderer . config ) ;
80
87
const prefixedEntries = this . config . renderer . prefixedEntries || [ ] ;
81
88
return merge . smart ( {
@@ -101,7 +108,7 @@ export class WebpackPlugin extends PluginBase<WebpackPluginConfig> {
101
108
} , rendererConfig ) ;
102
109
}
103
110
104
- async compileMain ( ) {
111
+ compileMain = async ( ) => {
105
112
await asyncOra ( 'Compiling Main Process Code' , async ( ) => {
106
113
await new Promise ( async ( resolve , reject ) => {
107
114
webpack ( await this . getMainConfig ( ) ) . run ( ( err , stats ) => {
@@ -112,7 +119,7 @@ export class WebpackPlugin extends PluginBase<WebpackPluginConfig> {
112
119
} ) ;
113
120
}
114
121
115
- async compileRenderers ( ) {
122
+ compileRenderers = async ( ) => {
116
123
for ( const entryPoint of this . config . renderer . entryPoints ) {
117
124
await asyncOra ( `Compiling Renderer Template: ${ entryPoint . name } ` , async ( ) => {
118
125
await new Promise ( async ( resolve , reject ) => {
@@ -125,7 +132,7 @@ export class WebpackPlugin extends PluginBase<WebpackPluginConfig> {
125
132
}
126
133
}
127
134
128
- async launchDevServers ( ) {
135
+ launchDevServers = async ( ) => {
129
136
await asyncOra ( 'Launch Dev Servers' , async ( ) => {
130
137
let index = 0 ;
131
138
for ( const entryPoint of this . config . renderer . entryPoints ) {
@@ -146,7 +153,7 @@ export class WebpackPlugin extends PluginBase<WebpackPluginConfig> {
146
153
} ) ;
147
154
}
148
155
149
- async spinDev ( ) {
156
+ async startLogic ( ) : Promise < false > {
150
157
await this . compileMain ( ) ;
151
158
await this . launchDevServers ( ) ;
152
159
return false ;
0 commit comments