Skip to content

ashokgelal/vapor-mix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vapor Mix

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.

Using in your Vapor project

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>

Building from the source

1: Clone it:

$ git clone https://github.com/ashokgelal/vapor-mix

2: Build it

$ swift build

3: Run the tests

$ swift test

To learn more

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:

Laravel Mix on GitHub

Compiling Assets on Laravel