Package mix implements convenience methods to integrate the Laravel Mix asset bundler in your Go project.
For more information on Laravel Mix, visit the Laravel Mix website.
go get -u github.com/ugent-library/mix
Setup your webpack.mix.js
:
const mix = require('laravel-mix')
mix.sass('./assets/css/app.scss', 'css')
mix.setPublicPath('./static')
// ...
And in your Go app:
// setup file server
mux := http.NewServeMux()
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
// setup assets
assets, err := mix.New(mix.Config{
ManifestFile: "static/mix-manifest.json",
PublicPath: "/static/",
})
if err != nil {
log.Fatal(err)
}
// make asset path helper available to templates
funcs := template.FuncMap{
"assetPath": assets.AssetPath,
}
// ...