adonis-mix

1.2.0 • Public • Published

adonis-mix

Laravel Mix for AdonisJS

NPM Badge

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.setPublicPath('public')
 
mix
  .js('resources/assets/js/app.js', 'public/js')
  .sass('resources/assets/scss/app.scss', 'public/css')

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"{
  ...
  "hot": "webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js"
  ...
}
...

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.

...
<head>
  {{ style(mix('css/app.css')) }} 
  {{ script(mix('js/app.js)) }}
</head>
...

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.2.06latest

Version History

VersionDownloads (Last 7 Days)Published
1.2.06
1.1.10
1.1.00
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i adonis-mix

Weekly Downloads

6

Version

1.2.0

License

MIT

Unpacked Size

8.2 kB

Total Files

9

Last publish

Collaborators

  • deathman92