When using Laravel Mix in your Vapor project, this package allows you to load appropriate hashed asset within your .leaf
view files without having to know the exact name of the asset.
1: In your Package.swift
file add Vapor Mix
as a dependency:
dependencies: [
.Package(url: "https://github.com/ashokgelal/vapor-mix.git", majorVersion: 1),
]
2: Register Mix
in your main.swift
file:
if let leaf = drop.view as? LeafRenderer {
leaf.stem.register(Mix())
}
3: After you have run npm run as described in this article, you can call the mix tag as such:
<link rel="stylesheet" href='#mix("/css/app.css")'>
<script src='#mix("/js/app.js")'></script>
1: Clone it:
$ git clone https://github.com/ashokgelal/vapor-mix
2: Build it
$ swift build
3: Run the tests
$ swift test
Vapor Mix is inspired by, and based on, Laravel's excellent front end package called Laravel Mix. As such, the documents are (very) identical. If you want to learn more, visit: