Laravel-mix: Laravel mix and Laravel package development

Created on 9 Mar 2017  路  3Comments  路  Source: JeffreyWay/laravel-mix

This is more a question then an issue. I tried to find solution but could not read anything on this topic so far.
Developing package in /packages/vendor/package/src
Having a resource/assets/scss and resource/assets/js folders.
webpack.mix.js does the job and mix js and style for me into a public folder so i can see results while developing package:
mix.js('packages/vendor/package/src/resources/assets/js/app.js', 'public/vendor/js') .sass('packages/vendor/package/src/resources/assets/sass/app.scss', 'public/vendor/css/app.css');
Plan is that later user of package can publish package: php artisan vendor:publish --tag=public
How my css and js from package will be published? they exists only in /packages/vendor/package/src/resources/assets and they are not mixed there.

Is it possible to have laravel mix to out put on more then one destination?
Eg mix.js('packages/vendor/package/src/resources/assets/js/app.js', ['public/vendor/js', 'another/destination/js'])

Or, if not, is it possible to have mix.copy to copy entire folder?
so, when mix.js and mix.sass create files in public/vendor/js and public/vendor/css we can just copy them in packages/vendor/package/src/public (for example)
mix.copy(['public/vendor/*'], 'packages/vendor/package/src/public');

Most helpful comment

I have same question, I want to develop a package and make it stand alone, ex: backend . and I want to use it for another project, but how can I config for webpack.mix.js? I need copy and paste it? or any way to create a file webpack.mix.js in package and call it from root website.mix.js?

All 3 comments

I have same question, I want to develop a package and make it stand alone, ex: backend . and I want to use it for another project, but how can I config for webpack.mix.js? I need copy and paste it? or any way to create a file webpack.mix.js in package and call it from root website.mix.js?

You can't have it output to more than one destination.

For your copy method, just remove the star, and it'll copy the whole directory.

mix.copy(public/vendor, 'packages/vendor/package/src/public');

You can copy your webpack.mix.js to your package and run npm with this argument :
npm run dev -- --env.mixfile vendor/YOUR-VENDOR/YOUR-PACKAGE/webpack.mix

Was this page helpful?
0 / 5 - 0 ratings

Related issues

terion-name picture terion-name  路  3Comments

jpriceonline picture jpriceonline  路  3Comments

dtheb picture dtheb  路  3Comments

RomainGoncalves picture RomainGoncalves  路  3Comments

hasnatbabur picture hasnatbabur  路  3Comments