Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
📓 Laravel-mix setup
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler36 committed Apr 15, 2022
1 parent 5ac2c75 commit 8abf189
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 18 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [Requirements](#requirements)
- [Setup](#setup)
- [Demo 1: Host with artisan server](#demo-1-host-with-artisan-server)
- [DDEV & Laravel mix](#ddev--laravel-mix)

## Intro

Expand Down Expand Up @@ -64,3 +65,34 @@ npm run watch

- Visit [http://127.0.0.1:8000](http://127.0.0.1:8000) in browser
- Update `./resources/views/welcome.blade.php` and confirm browser refreshed.

### DDEV & Laravel mix

- Install NPM packages in DDEV

```shell
ddev exec npm install
```

- Add [browsersync](https://laravel-mix.com/docs/4.0/browsersync) to Laravel Mix's `./webpack.mix.js`
- Replace `$DDEV_HOSTNAME` with your site's hostname.

```js
let url = $DDEV_HOSTNAME;

mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
//
])
.browserSync({
proxy: url,
host: url,
open: false,
});
```

- Run the watcher. Note: On the first attempt, Laravel-mix may download additional required packages.

```shell
ddev exec npm run watch
```
50 changes: 33 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion webpack.mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ const mix = require('laravel-mix');
| file for the application as well as bundling up all the JS files.
|
*/
let url = 'browsersync-demo.ddev.site';

mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
//
])
.browserSync('127.0.0.1:8000');
.browserSync({
proxy: url,
host: url,
open: false,
});

0 comments on commit 8abf189

Please sign in to comment.