admin管理员组文章数量:1402165
Previously I would use NPM for server side stuff and Bower for frontend. NPM would install to the node_modules/
directory and I had a .bowerrc
to install those packages to public/lib
.
Now I've begun to use Yarn instead of NPM; and since they are pretty much 1:1 patible it has been a smooth change.. However, now I'm wondering if I can ditch Bower and just use Yarn for everything. But I do not see a way (in either NPM or Yarn) to install normal packages to node_modules, but then have a sort of separate option to put some packages in public/
... Something similar to the --dev
option but instead it would be yarn add jquery --public
. Does anything like this exist?
One option, of course, would be to install all packages to the public/
directory but I believe this is a bad practice (correct me if I'm wrong).
Another option might be to have a separate package.json
in the public/
folder and run separate Yarn mands in there for frontend packages, but it's just a bit less convenient, I think; more error prone.
Previously I would use NPM for server side stuff and Bower for frontend. NPM would install to the node_modules/
directory and I had a .bowerrc
to install those packages to public/lib
.
Now I've begun to use Yarn instead of NPM; and since they are pretty much 1:1 patible it has been a smooth change.. However, now I'm wondering if I can ditch Bower and just use Yarn for everything. But I do not see a way (in either NPM or Yarn) to install normal packages to node_modules, but then have a sort of separate option to put some packages in public/
... Something similar to the --dev
option but instead it would be yarn add jquery --public
. Does anything like this exist?
One option, of course, would be to install all packages to the public/
directory but I believe this is a bad practice (correct me if I'm wrong).
Another option might be to have a separate package.json
in the public/
folder and run separate Yarn mands in there for frontend packages, but it's just a bit less convenient, I think; more error prone.
- 2 Personally I would separate the public folder from the backend folder and manage the dependencies separately. This will give you a better overview of the dependencies per 'project' – Angular Dev Commented Oct 16, 2017 at 16:49
-
If you use build tools like grunt/gulp to concat/minify your stuff then you can install using npm and point your grunt config to
node_modules
. – user2652134 Commented Oct 16, 2017 at 17:05
1 Answer
Reset to default 7The norm pretty much is something like:
- Install packages via
yarn
- Use a task runner such as
gulp
, or module loader & bundler such aswebpack
to create the bundles you need.- This all depends on your stack, there are obviously others, for example in the past I've used .NET's native bundling, which you can achieve the same as gulp/webpack... again this is for you to decide.
The gist of it is, install all the modules in a central place (using a package manager), then have a loader or other process grab and move the required assets to the location that you need to use them.
I'd suggest having a look at a kickstart project (pertaining to the stack that you're using) eg: I've used : Fountainjs in the past with success, or look into Yeoman if fountain doesnt strike your fancy (fyi. Fountain is built on top of Yeoman)
In pseudo mands:
1. yarn install /// installs all assets
2. gulp build /// cleans out current public folder, bundles & copies new
3. gulp serve /// runs your app
本文标签: javascriptHow to use one package manager for backend and frontend (YarnNPM)Stack Overflow
版权声明:本文标题:javascript - How to use one package manager for backend and frontend? (YarnNPM) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744343607a2601625.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论