morrislaptop / WebpackDevServerValetDriver

11 stars 8 forks source link

index.html returned for any url on valet domain for new vue app #10

Open pieterjandebruyne opened 4 years ago

pieterjandebruyne commented 4 years ago

I wanted to use these drivers to serve my vue apps over valet ( I am already using valet for all my other web related projects )

I copied the drivers and valet linked my newly cli generated vue project.

I changed line 232 in WebpackDevServerBaseDriver.php to: putenv('PATH=/usr/local/opt/node@12/bin:/bin'); pointing to the bin folder with npm inside (I use homebrew for my node install)

If I go to the domain it injected the js link tags in the index.html: http://vueapp.test/js//127.0.0.1:1744/app.js But when you inspect this .js script, the content is the same as index.html instead of the js code (so the code crashes on the first < symbol of the html tag.)

Also if I inspect this app.js url on the localhost:8080 domain (with npm run serve instead of valet) it shows /js/app.js ..

Any page I visit on the domain just serves the index.html with the <div id="app"></div> ( http://vueapp.test/anything-will-return-index -> So also the /js/... file content is html. )

I restarted valet and also my macbook couple of times without results. Is there any more config that needs to be done ?

When I look inside the out file I see valet is running the app @ http://localhost:1744/ when I go to this url, everything is served as it should but not on vueapp.test.

using: Laravel Valet 2.11.0 @vue/cli 4.4.6

pieterjandebruyne commented 4 years ago

I changed this function:

protected function filterDevContent($content)
    {
        return str_replace('/js/app.js', "//{$this->devServerHost}:{$this->port}/js/app.js", $content);
    }

this seems to work in my first tests..

added it here: https://github.com/morrislaptop/WebpackDevServerValetDriver/compare/master...pieter-janDB:patch-1