adonis-mix
Laravel Mix for AdonisJS
Adonis Mix is assets bundler your AdonisJs application.
It's based on Laravel Mix which is a super easy tool to configure webpack
.
Getting Started
This package should be installed with the Adonis CLI.
$ adonis install adonis-mix
Then register the Service Provider within your start/app.js
file.
const providers = 'adonis-mix/providers/AssetsProvider'
You are now ready to go!
Bundle the assets
On installation adonis-mix
copies webpack.mix.js
configuration file to the project's root folder. See See Laravel Mix Documentation to how to setup your assets.
After creating your assets in the way you want (Less, SCSS, Stylus, ES2015, ...) you simply need to run the command below and the magic will happen.
$ adonis assets# adonis assets --watch -> Watch for change # adonis assets --prod -> Minify for production
Laravel Mix will automaticaly download packages you need to compiles your assets and will then run them.
Config
The config file is Laravel Mix webpack.mix.js
file.
Example configuration
For simple AdonisJS project you can use following configuration
mix mix
Add these to webpack.mix.js
file in project's root.
Hot Module Replacement
Read Laravel Mix instructions about HMR.
You can add script to your package.json
..."scripts": ...
And run dev server with
npm run hot
View Helper
Also this package adds mix
view helper, that parses mix-manifest.json
file to generate urls to assets.
... {{ style(mix('css/app.css')) }} {{ script(mix('js/app.js)) }}...