andrelandgraf / laravel-docker

A walking skeleton for a web app using laravel 5.6 and docker.
2 stars 0 forks source link

Setting up Webpack via Laravel Mix #14

Open andrelandgraf opened 6 years ago

andrelandgraf commented 6 years ago

Webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging.

Laravel Mix is an abstraction layer on top of Webpack.

andrelandgraf commented 6 years ago

Current browser do not yet support all es6 features, like modules. However, using modules is essential for writing clean and readable javascript code. Laravel Mix is a layer on top of webpack to bundle css and js files after self defined rules.

This gives us the possibility to work with all of today`s css preprocessors (sass, scss, ...) and to maintain a more sophisticated js folder structure.

andrelandgraf commented 6 years ago

Laravel Mix also abstracts ESLint: https://www.npmjs.com/package/laravel-mix-eslint

=> I had some problems getting the laravel-mix-eslint npm package running and now removed it. For now, ESLint will run on its own.

andrelandgraf commented 6 years ago

Move js-folder structure from public/js to assets/js: Done 👍
Add laravel mix command to build js files into public/js: Done 👍 TODO: select css preprocessor for the example component (see #3)

andrelandgraf commented 6 years ago

nice instructions for how to get webpack running without laravel mix: https://github.com/wesbos/es6.io/blob/master/13%20-%20JavaScript%20Modules%20and%20Using%20npm/es6-module-instructions.md

andrelandgraf commented 6 years ago

Getting some help with Laravel Mix from reddit: https://www.reddit.com/r/laravel/comments/93py75/larvel_mix_how_to_debug/