1.2.0 • Published 5 years ago

adonis-mix v1.2.0

Weekly downloads
12
License
MIT
Repository
github
Last release
5 years ago

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>
...
1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago