@@ -57,6 +57,10 @@ public function handle()
5757 $ this ->assets ($ name );
5858 }
5959
60+ if ($ this ->confirm ('Create a webpack helper kit? ' ,true )) {
61+ $ this ->webpack ($ name );
62+ }
63+
6064 $ this ->info ("Theme Generator Successful. Now add your default theme from the config/theme settings. " );
6165 return ;
6266 }
@@ -81,7 +85,7 @@ protected function template($themeName)
8185 $ this ->config ['views_folder ' ]['component ' ].'. ' .$ this ->config ['views_blade ' ]['header ' ],
8286 $ this ->config ['views_folder ' ]['component ' ].'. ' .$ this ->config ['views_blade ' ]['footer ' ]
8387 ],
84- $ this ->getStub ('layout ' )
88+ $ this ->getStub ('View ' , ' layout ' )
8589 );
8690
8791 $ indexTemplate = str_replace (
@@ -91,7 +95,7 @@ protected function template($themeName)
9195 [
9296 $ this ->config ['views_folder ' ]['layout ' ].'. ' .$ this ->config ['views_blade ' ]['layout ' ],
9397 ],
94- $ this ->getStub ('index ' )
98+ $ this ->getStub ('View ' , ' index ' )
9599 );
96100
97101 $ this ->setFile ('resources ' ,$ themeName .'/views/ ' .$ this ->config ['views_folder ' ]['layout ' ],$ this ->config ['views_blade ' ]['layout ' ].'.blade.php ' ,$ layoutTemplate );
@@ -127,9 +131,35 @@ protected function assets($themeName)
127131
128132 }
129133
130- protected function getStub ($ fileName )
134+ protected function webpack ($ name )
135+ {
136+ $ this ->setFolder ('resources ' ,$ name .'/assets ' );
137+ $ this ->setFolder ('resources ' ,$ name .'/assets/ ' .$ this ->config ['webpack ' ]['folder ' ]['js ' ]);
138+ $ this ->setFolder ('resources ' ,$ name .'/assets/ ' .$ this ->config ['webpack ' ]['folder ' ]['css ' ]);
139+
140+ // Include Js Files
141+ $ this ->setFile ('resources ' ,$ name .'/assets/ ' .$ this ->config ['webpack ' ]['folder ' ]['js ' ],$ this ->config ['webpack ' ]['file ' ]['js ' ],$ this ->getStub ('Webpack ' ,'js ' ));
142+ $ this ->setFile ('resources ' ,$ name .'/assets/ ' .$ this ->config ['webpack ' ]['folder ' ]['js ' ],$ this ->config ['webpack ' ]['file ' ]['bootstrap ' ],$ this ->getStub ('Webpack ' ,'bootstrap ' ));
143+
144+ // Include Css Files
145+ $ this ->setFile ('resources ' ,$ name .'/assets/ ' .$ this ->config ['webpack ' ]['folder ' ]['css ' ],$ this ->config ['webpack ' ]['file ' ]['css ' ],$ this ->getStub ('Webpack ' ,'css ' ));
146+ $ this ->setFile ('resources ' ,$ name .'/assets/ ' .$ this ->config ['webpack ' ]['folder ' ]['css ' ],$ this ->config ['webpack ' ]['file ' ]['variable ' ],$ this ->getStub ('Webpack ' ,'variable ' ));
147+
148+ // webpack.mix.js Added
149+ $ include_js = 'resources/ ' .$ this ->config ['resource_path ' ].'/ ' .$ name .'/assets/ ' .$ this ->config ['webpack ' ]['folder ' ]['js ' ].'/ ' .$ this ->config ['webpack ' ]['file ' ]['js ' ];
150+ $ export_js = 'public/ ' .$ this ->config ['public_path ' ].'/ ' .$ name .'/js ' ;
151+
152+ $ include_css = 'resources/ ' .$ this ->config ['resource_path ' ].'/ ' .$ name .'/assets/ ' .$ this ->config ['webpack ' ]['folder ' ]['css ' ].'/ ' .$ this ->config ['webpack ' ]['file ' ]['css ' ];
153+ $ export_css = 'public/ ' .$ this ->config ['public_path ' ].'/ ' .$ name .'/css ' ;
154+
155+ File::append (base_path ('webpack.mix.js ' ), "\n" . implode ("\n" , ["mix.js(' " .$ include_js ."', ' " .$ export_js ."').sass(' " .$ include_css ."', ' " .$ export_css ."').version(); " ]));
156+
157+
158+ }
159+
160+ protected function getStub ($ folder ,$ fileName )
131161 {
132- return File::get (__DIR__ .'/../Template/ ' .$ fileName .'.stub ' );
162+ return File::get (__DIR__ .'/../Template/ ' .$ folder . ' / ' . $ fileName .'.stub ' );
133163 }
134164
135165 protected function getDirectory ($ folder ,$ path = NULL )
@@ -138,18 +168,18 @@ protected function getDirectory($folder,$path = NULL)
138168 {
139169 if ($ path === NULL )
140170 {
141- return resource_path ($ this ->config ['theme_path ' ]);
171+ return resource_path ($ this ->config ['resource_path ' ]);
142172 }
143- return resource_path ($ this ->config ['theme_path ' ].'/ ' .$ path );
173+ return resource_path ($ this ->config ['resource_path ' ].'/ ' .$ path );
144174 }
145175
146176 if ($ folder === 'public ' )
147177 {
148178 if ($ path === NULL )
149179 {
150- return public_path ($ this ->config ['asset_path ' ]);
180+ return public_path ($ this ->config ['public_path ' ]);
151181 }
152- return public_path ($ this ->config ['asset_path ' ].'/ ' .$ path );
182+ return public_path ($ this ->config ['public_path ' ].'/ ' .$ path );
153183 }
154184
155185 }
@@ -172,17 +202,17 @@ protected function setFolder($directory,$path = null)
172202 {
173203 if ($ path == null )
174204 {
175- return File::makeDirectory (resource_path ($ this ->config ['theme_path ' ]));
205+ return File::makeDirectory (resource_path ($ this ->config ['resource_path ' ]));
176206 }
177- return File::makeDirectory (resource_path ($ this ->config ['theme_path ' ]).'/ ' .$ path );
207+ return File::makeDirectory (resource_path ($ this ->config ['resource_path ' ]).'/ ' .$ path );
178208 }
179209 if ($ directory === 'public ' )
180210 {
181211 if ($ path == null )
182212 {
183- return File::makeDirectory (public_path ($ this ->config ['theme_path ' ]));
213+ return File::makeDirectory (public_path ($ this ->config ['resource_path ' ]));
184214 }
185- return File::makeDirectory (public_path ($ this ->config ['theme_path ' ]).'/ ' .$ path );
215+ return File::makeDirectory (public_path ($ this ->config ['resource_path ' ]).'/ ' .$ path );
186216 }
187217 }
188218}
0 commit comments