balping / asset-bundler
Bundles assets for Laravel Mix from Laravel Modules
Requires
- balping/laravel-version: ^1.0
- illuminate/console: 5.5.*|5.6.*
- illuminate/support: 5.5.*|5.6.*
- matthiasmullie/path-converter: ^1.1
- nwidart/laravel-modules: ~2.6.0|~3.0.0|~3.1.0|~3.2.0
README
This package provides a command that generates a js
and an scss
file that bundles all assets provided by each of your modules.
Install
composer require --dev balping/asset-bundler
This package is auto-discovered by Laravel, there's no need to register the provider manually.
Usage
Modules should include index.js
and index.scss
files. Example file structure:
project-root/
├── Modules/
├── MyModule/
├── Resources/
├── assets/
├── js/
├── index.js
├── sass/
├── index.scss
├── npm
├── package.json
Running
php artisan module:bundle-assets
generates modules.js
and modules.scss
files in your main assets directory that you can require in app.js
and import in app.scss
:
require('./modules');
@import "modules";
Your module can have node dependencies too. If there's a package.json
in the root of a module, asset bundler creates the file resources/installed-modules/package.json
that requires your module's package.json
as a dependency. So if you add the following to your main package.json
file, all node dependencies of your modules will be required.
{
"private": true,
"scripts": {
// ...
},
"devDependencies": {
// ...
"installed-modules": "file:resources/installed-modules"
}
}
License
This library is licensed under GPLv3.