File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ .idea
2+ .DS_Store
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " rootstudio/base-mix-helper" ,
3+ "description" : " Mix standalone function for versioning assets outside of Laravel" ,
4+ "type" : " library" ,
5+ "license" : " none" ,
6+ "authors" : [
7+ {
8+ "name" : " James Wigger" ,
9+ "email" : " james@rootstudio.co.uk"
10+ }
11+ ],
12+ "require" : {
13+ "php" : " >=5.4.0"
14+ },
15+ "autoload" : {
16+ "files" : [" mix.php" ]
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * Return path to document root
5+ *
6+ * @param string $path
7+ *
8+ * @return string
9+ */
10+ if (!function_exists ('public_path ' )) {
11+ function public_path ($ path = '' )
12+ {
13+ return $ _SERVER ['DOCUMENT_ROOT ' ] . ($ path ? '/ ' . trim ($ path , '/ ' ) : $ path );
14+ }
15+ }
16+
17+ /**
18+ * Parse manifest and output versioned asset path
19+ *
20+ * @param string $path
21+ * @param string $manifestDirectory
22+ *
23+ * @return string
24+ * @throws Exception
25+ */
26+ if (!function_exists ('mix ' )) {
27+ function mix ($ path , $ manifestDirectory = '' )
28+ {
29+ static $ manifest ;
30+
31+ $ path = '/ ' . ltrim ($ path , '/ ' );
32+
33+ if ($ manifestDirectory ) {
34+ $ manifestDirectory = '/ ' . ltrim ($ manifestDirectory , '/ ' );
35+ }
36+
37+ if (!$ manifest ) {
38+ if (!file_exists ($ manifestPath = public_path ($ manifestDirectory . '/mix-manifest.json ' ))) {
39+ throw new Exception ('The Mix manifest does not exist. ' );
40+ }
41+
42+ $ manifest = json_decode (file_get_contents ($ manifestPath ), true );
43+ }
44+
45+ if (!array_key_exists ($ path , $ manifest )) {
46+ throw new Exception (
47+ "Unable to locate Mix file: {$ path }. Please check your " .
48+ 'webpack.mix.js output paths and try again. '
49+ );
50+ }
51+
52+ if (file_exists (public_path ($ manifestDirectory . '/hot ' ))) {
53+ return "http://localhost:8080 {$ manifest [$ path ]}" ;
54+ }
55+
56+ return $ manifestDirectory . $ manifest [$ path ];
57+ }
58+ }
You can’t perform that action at this time.
0 commit comments