[英]Build ember-cli addon without dependencies
I developed an ember-cli addon that works fine. 我开发了一个工作正常的ember-cli插件。
When I run the command ember build
, it basically creates a vendor.js
file that contains my addon and all dependencies (ember, jquery etc...) which is about 3MB 当我运行命令
ember build
,它基本上创建了一个vendor.js
文件,其中包含我的插件和所有依赖项(ember,jquery等...),大约3MB
I'd like to know if it's possible to export the addon as its own ( my-addon.js
) without any dependencies inside, as a vendor I can use? 我想知道是否有可能将插件导出为自己的(
my-addon.js
),而不是内部依赖,作为我可以使用的供应商?
I'm basically trying to make my ember-cli addon a bower component that I can include in another ember project. 我基本上试图让我的ember-cli插件成为一个可以包含在另一个ember项目中的bower组件。 My addon and all dependencies are more than 100MB of data (including node modules, broccoli, tests...), so when I install it using npm install my-addon, it's pretty big.
我的插件和所有依赖项都超过100MB的数据(包括节点模块,西兰花,测试...),所以当我使用npm install my-addon安装它时,它非常大。 I don't really need that in my other project, the addon itself (dist version) is about a couple of KB and that's all I need...
我真的不需要在我的其他项目中,插件本身(dist版本)大约是几KB,这就是我所需要的......
Basically, this is the architecture of my projects: 基本上,这是我的项目的架构:
Ember project: 灰烬项目:
my-project.git 我-project.git
/my-project
/app
/controllers etc...
/node_modules
/my-addon //My addon lives here for now and contains everything (all node_modules, bower_components, tests... about 100MB to download!)
Brocfile.js etc..
Basic architecture for an ember-cli addon: ember-cli插件的基本架构:
my-addon.git 我-addon.git
/my-addon
/addon
/app
/bower_components
/node_modules
/tests
Brocfile.js etc..
package.json: 的package.json:
{
"name": "my-addon",
"version": "0.0.1",
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"start": "ember server",
"build": "ember build",
"test": "ember test"
},
"engines": {
"node": ">= 0.10.0"
},
"devDependencies": {
"body-parser": "^1.2.0",
"broccoli-sass": "0.3.2",
"broccoli-asset-rev": "0.3.1",
"broccoli-ember-hbs-template-compiler": "^1.6.1",
"ember-cli": "0.1.2",
"ember-cli-content-security-policy": "0.3.0",
"ember-cli-ic-ajax": "0.1.1",
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-qunit": "0.1.0",
"ember-data": "1.0.0-beta.10",
"ember-export-application-global": "^1.0.0",
"express": "^4.8.5",
"glob": "^4.0.5"
}
"keywords": [
"ember-addon"
],
"ember-addon": {
"configPath": "tests/dummy/config"
}
}
Thanks 谢谢
So, what happened? 所以发生了什么事?
My answer would be, that your local repo - should have all that junk that it needs to process etc... but the final code that you set up with bower, should be a either a branch with just your /dist or something or - the github repo should only have the unbuilt code. 我的答案是,你的本地回购 - 应该有它需要处理的所有垃圾等......但是你用bower设置的最终代码应该是一个只有你的/ dist或者某个东西的分支或者 - github repo应该只有未构建的代码。 Then... you
bower install --save your-thing
- which would then get registered with the ember app. 然后......你下载
bower install --save your-thing
- 保存bower install --save your-thing
- 然后将在ember应用程序中注册。 then just bower install
or update
etc - and it will check the config - and pull in the dependencies based on the package.json
and the bower.json
. 然后只是
bower install
或update
等 - 它将检查配置 - 并根据package.json
和bower.json
拉入依赖bower.json
。
It would be great if you documented your findings and answered this question here. 如果你记录了你的发现并在这里回答了这个问题,那就太棒了。 I bet it's a pretty common workflow.
我敢打赌这是一个非常常见的工作流程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.