R
R
Roman Dubinin2017-07-03 10:42:07
css
Roman Dubinin, 2017-07-03 10:42:07

How to make js, css packages for Laravel?

I started to transfer the old project to Laravel 5.4 and there was a desire to move some parts of the js code into separate packages in order to use them in other projects later. And I'm completely confused in all these npm, webpack, bower, elixir, laravel-mix and the rest of a bunch of tools ...
At first I thought that it would be better to make composer packages, because then artisan will throw all the files for me where necessary when updating, but this is a crookedness, because there will be trouble with dependencies, and in general composer for php, as I understand it ...
Then I decided that apparently I need to create npm packages, but here I was already lost, trying to figure out how it is for the web arrange (in the sense of how to add more css there)
Tell me the right solution, or some article on the design of your packages and adding to the project.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav, 2017-07-03
@romash

generally composer for php

No, but in general it's the right decision, don't use it for this kind of purposes unless you keep a close eye on the dependencies.
It is also a wrong decision, since using this tool for such purposes is like shooting sparrows from a cannon.
Once again on the previous points - composer really collects mainly for the backend (conditionally the engine), although they can also hammer nails. NPM collects for some backend needs, including administrative ones, for example, Bower is installed through it. Including because for each package, all its dependencies are pulled into its folder, each time for each package, even if the packages on which they depend are common.
But the same Bower can and should be used to pull up packages for the front. Elixir, laravel-mix - these are all assemblers, like the same Gulp, they do not install packages, but convert them - for example, they minify and concatenate style files or scripts, these are completely different tasks.
Therefore, I would suggest you use Bower, but, again, do not publish your packages for it in the public domain, unless they have value for the whole community as a whole (meaning to pollute the common eco-environment), but use your personal Github or whatever whatever your public server/etc. You can read more about how to install packages from a non-shared repository here , but in general, everything is quite simple there:
# Git endpoint
$ bower install git://github.com/user/package.git
# URL
$ bower install http://example.com/script.js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question