分离前端和前端带有Gulp/Yarn的后端依赖项 [英] Separating Frontend & Backend Dependencies with Gulp/Yarn
问题描述
我想使用yarn
代替bower
+ npm
. Yarn使用package.json,并且在前端和后端程序包之间不分开.
I want to use yarn
instead of bower
+ npm
. Yarn uses package.json and does not separate between frontend and backend packages.
到目前为止,我需要用gulp分隔前端+后端依赖项: 如何使用一个包管理器作为后端和前端? (纱线/NPM)
I read so far, that I need to separate my frontend + backend dependencies with gulp: How to use one package manager for backend and frontend? (Yarn/NPM)
我的应用程序使用MEAN堆栈.目前,我正在使用wiredep
将所有前端依赖项注入到我的index.html
中.
My app uses the MEAN stack. Currently, I'm using e.g. wiredep
to inject all frontend dependencies into my index.html
.
问题: 在构建过程中如何自动将前端依赖项与后端依赖项分开?/是否可以使用yarn指定前端/后端程序包?
Question: How can I automatically separate the frontend dependencies from the backend dependencies in my build process?/Is there any option to specify frontend/backend packages with yarn?
推荐答案
让我介绍 handpick 使您可以定位和过滤多个依赖项.我写这篇文章是为了加快CI阶段,这些阶段只需要devDependencies的一部分,但最终会有更多用例.这个项目是实验性的-请留下一些反馈.
Let me introduce handpick that lets you target and filter multiple dependencies. I wrote this to speed up CI stages that just need a fragment of the devDependencies but there are eventually more usecases. This project is quite experimental - please leave some feedback.
在您的系统上安装:
npm install handpick --global
用法
运行命令:
Usage
Run the command:
handpick [options]
-V, --version
-T, --target
-F, --filter
-M, --manager
-P, --path
-h, --help
示例
在package.json
文件中定义非官方的依赖项:
Examples
Define unofficial dependencies inside package.json
file:
{
"lintDependencies":
{
"eslint": "6.8.0",
"eslint-config-redaxmedia": "2.0.0"
},
"testDependencies":
{
"chai": "4.2.0",
"mocha": "7.1.1"
}
}
安装lintDependencies
:
handpick --target=lintDependencies
通过YARN安装devDependencies
和lintDependencies
:
handpick --target=devDependencies --target=lintDependencies --manager=yarn
安装不带testDependencies
的devDependencies
:
handpick --target=devDependencies --filter=testDependencies
在路径中安装dependencies
和devDependencies
:
handpick --path=../shared
这篇关于分离前端和前端带有Gulp/Yarn的后端依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!