Laravel: Import Templates into Laravel
We know, there’s millions of web templates available out there – the clean look, corporate look, modern, minimalist. You name it, either it is free or paid version, usually it come in HTML, JS and CSS format. It’s hard to find template that is ready with Laravel.
Previously, here are some of the approaches I did, to get the template into Laravel application.
- Download the template, copy the assets, organise them in
publicdirectory. That’s ok, but I need a way to keep everything in
resources/assetsand start writing codes for front-end assets, then compile using Laravel Mix.
- Get the list of dependencies used for the theme, manually install using
resources/assets, then compile using Laravel Mix.
All these some of my previous approaches in importing templates into Laravel application.
Yesterday, I have a chance experimenting on new method. Here the workflow:
- Clone / Download the template into
- In terminal, go into
npm install && npm run build– depending on your template selection, sometimes it is required to compile the template, but there is templates that did not require you to compile.
- Then in
webpack.mix.js, copy all assets generated in
Then you are done! You can start use the
asset() helper like
asset('the-template/js/vendor.js'), and so on in your layouts.
Following an example of the templates I have compile and export to public folders – but I did not implement in the new layout, as it require a lot of efforts to create components and use all the classes from the template.
Hope my explanation will make you guys clear, how to import templates into Laravel projects – 3 main steps: git clone, build(optional), copy compiled assets with mix to public directory.