I am using laravel 7. How can I use Babel with mix.combine ?
I can find something in the docs but only mentions vue and react automatically using Babel?
I am used tot Gulp and not Webpack. With Gulp I just use it for converting es6 to es5.
Laravel mix is a wrapper around webpack, so using gulp isn't configureable
Seeing as your setup isn't doing much, I would swap to using webpack
Related
Bit of a "first steps" question this one.
I am working on a project that uses gulp, and have found a nice vue component that I would like to incorporate.
I have been recommended to use Laravel mix, but will installing mix mess up the current installation ?
Is there a good way to use vue with gulp ? is doing this "safer" than running gulp and laravel mix ?
I am not new to Laravel but am new to JavaScript frameworks.
I want to use React in a laravel build but cannot find any information on how to do this.
I have Laravel 5.4. I know this comes pre-packed with Vue and Laravel Mix instead of Gulp.
I am following the tutorial here: https://blog.tighten.co/adding-react-components-to-a-laravel-app but this is not meant for 5.4. It mentions needing to update the gulpfile but, since Laravel 5.4 doesn't use Gulp, there isn't one!
Can someone please help with a small tutorial or a couple of steps that I need to replicate in order to get React working in 5.4?
I have Googled but can only find NPM links, which are less than useful!
Thanks to Joe for pointing out the part of the docs that I needed. There was a little more to it so will describe my steps below to help anyone else out.
Delete the node_modules folder. This isn't necessary for brand new builds but if you have followed any other tutorials and installed things you don't need, this will save a few headaches. If you don't have a node_modules folder, ignore this step.
Please note that the above step will remove anything you have installed using NPM.
Run npm install from your project root. This will install all NPM components used by Laravel.
Open webpack.mix.js and change:
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css');
to
mix.react('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css');
Run npm run dev to compile the Javascript from the lesson contained in the question above. Your React JS outputs should now be working.
(optional) Use npm run watch to compile on the fly.
I really hope this helps someone else out as much as it helped me!
According to the docs, React support is built in to Mix:
Mix can automatically install the Babel plug-ins necessary for React support. To get started, replace your mix.js() call with mix.react():
mix.react('resources/assets/js/app.jsx', 'public/js');
Behind the scenes, Mix will download and include the appropriate babel-preset-react Babel plug-in.
I'm not 100% sure whether or not this'll automatically include React in your output bundle - my guess would be no (in which case you'll have to use a normal mix.js() call to pull it in).
I'm completely new to laravel mix and npm in general so I'm at total loss here.
I'm using jquery plugins such as: https://github.com/noraesae/perfect-scrollbar
Now, I installed laravel mix since I needed laravel echo.
Got that working and running up, but since then the jquery plugins are not loading, all I'm getting is:
Uncaught TypeError: $(...).perfectScrollbar is not a function
I don't know, is this perhaps that the jquery is now loaded async and Mix overwrites the one which I have set up /div> way?
However, I noticed I could perhaps install this plugin via npm due to documentation via:
npm install perfect-scrollbar
I did that, it installed but how can I now possibly include it so that laravel mix loads it as well? I've spent the last 6 hours trying to find a way but I just can't understand how to do this. Any help would be greatly appreciated!
Ok... not sure I get where your problem is but here is a few things you can check...
First, mix will run webpack... wbpack.mix.js ... which will contain something like this if you did not change it:
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css');
Now, this will run webpack and compile your resources... in the case we are interested in here, app.js.
Did you include your library (perfect-scrollbar) in app.js as suggested in the perfect scrollbar doc?
var Ps = require('perfect-scrollbar');
You will also need to take care of the css for it as well.. by importing it in your app.scss ... if you are using sass as in the standard laravel install...
#import "node_modules/perfect-scrollbar/src/css/main.scss"
Rebuild and you should be good to go if you use Ps as the perfect-scrollbar object. You can also add it to the window instead... like window.Ps = require...
npm install just installs the package in your node_modules directory. Once there, you must import them into your compiled css and js application file.
Hope this helps.
I've tried everything I've found to setup laravel 5.3 with elixir + webpack + vue + hot module reload and I can't achieve it.
When I do gulp watch I can't run the webpack dev server with hot module reload. I've searched for a solution for a few days and I haven't found anything.
Do you know how to set it up?
I've just been trying to figure this out myself and discovered the new replacement for Elixir: Mix. I've just installed it on an existing Laravel 5.3 app and I now have HMR with webpack. See the instructions to install it here: https://github.com/JeffreyWay/laravel-mix/tree/master/docs
Hope this helps
https://laracasts.com/discuss/channels/vue/how-to-elixir-vue-browsersync-vueify-hotreload
Since elixir does a lot of magic behind the scene, it can be tricky to add something like vueify hot reload.
I've read that SASS uses Ruby to compile. I have a webhosting at One.com, I don't think they support Ruby. Am I able to run SASS on it?
You actually do not need to use ruby to compile sass. There are a few alternatives.
If you are using Laravel 5 you can do this with the new elixir feature which uses gulp to process tasks.
Or you could use gulp along side Laravel 4.
Or you could use grunt.
All of these options use libsass in the background instead of ruby.
Usually SASS is compiled in CSS in development and the production server only serves the CSS.
You would need Ruby if you wanted to compile SASS though. Sometimes that's needed to create more dynamic stylesheets although I'd generally advice against it because it slows down performance.