- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在开发一个项目,其中我们有一个父级 Web 应用程序(恰好是一个 AngularJS 应用程序)和多个子 Bower 模块(包含 Javascript、SASS、图像等),这些模块包含在使用 Bower 的父级中.
例如,父 Bower.json 如下所示:
{
"name": "parent-app",
"version": "1.0.0",
"dependencies": {
"child-1-module": "1.0.0",
"child-2-module": "1.0.0"
}
}
在父模块上执行“bower install”时,子模块将安装到:
bower_components/child-1-module
bower_components/child-2-module
然后,我们为每个子模块使用“bower link”。
然后在父级上使用 'bower link child-1-module' 和 'bower link child-2-module' 创建本地软链接(soft link),例如:
bower_components/child-1-module -> /some/where/else/child-1-module
bower_components/child-2-module -> /some/where/else/child-2-module
这使我们能够在本地对各个子模块进行更改,并在父应用程序中查看结果。
然后,我们还在父级中使用 Grunt 和 grunt-contrib-watch 来监视父级应用程序的更改,然后执行其他 Grunt 任务,或者执行“livereload”来刷新用于查看应用程序的浏览器。
下面是一个简化的 Gruntfile.js 示例,它监视 .js 文件,然后执行“jshint”任务和“livereload”:
grunt.initConfig({
// Watches files for changes and runs tasks based on the changed files
watch: {
js: {
files: [
'scripts/{,*/}*.js',
],
tasks: ['newer:jshint:all'],
options: {
livereload: true
}
}
}
}
这对于观察父应用程序的更改非常有效,但我们也想知道子模块中的文件何时发生更改。目前我已经想到/研究了许多解决方案,结果好坏参半。
所以我可以修改 Gruntfile 以另外查看 Bower_components 文件夹中的 .js 文件,如下所示:
grunt.initConfig({
// Watches files for changes and runs tasks based on the changed files
watch: {
js: {
files: [
'scripts/**/*.js',
'bower_components/**/*.js'
],
tasks: ['newer:jshint:all'],
options: {
livereload: true
}
}
}
}
然而,可能有许多子模块(包含许多 .js 文件),因此性能会急剧下降,甚至经常由于“EMFILE:打开的文件太多”问题而无法运行(请参阅 here )。
此外,子模块是动态添加的,因此我们不能在 Gruntfile 中预先指定特定的模块,例如:
'bower_components/child-1-module/**/*.js'
我们可以在每个子模块中添加一个 Gruntfile.js,其中包含一个监视程序来监视自己的文件。
当子模块中的文件发生更改时,我们可以更新特定的“livereload”文件,然后在父模块中我们只能监视这些特定文件。
child-module-1 中的示例“Gruntfile.js”
grunt.initConfig({
watch: {
js: {
files: ['scripts/**/*.js'],
tasks: ['livereloadEvent:js', 'newer:jshint:all']
}
}
}
grunt.registerTask('livereloadEvent', function() {
// create a 'livereload/livereload.{arg}' file for the event specified
grunt.file.mkdir('livereload');
for(var i = 0; i < this.args.length; i++) {
// contents of the file is the current timestamp
grunt.file.write('livereload/livereload.'+ this.args[i], new Date());
}
});
然后在父级中我们可以将以下文件夹添加到我们的 watch 中:
'bower_components/**/livereload/livereload.js'
这工作正常。父级现在不必观看太多文件,现在由子级执行自己的观看并基本上通知父级。
缺点是每个 child 都必须意识到这一点并以相同的方式实现这一点。
其他人还如何处理这个问题?是否有公认且广泛使用的模式来处理此问题?
最佳答案
我们处理此问题的方式与您建议的解决方案 2 非常相似。
当开发人员处理子组件时,他会设置从子组件到父 Angular 应用程序的 Bower 链接。
他打开了两个终端窗口。一个在子级上运行 grunt watch
任务,另一个在父级上运行 grunt watch
任务。
当他对子组件进行更改时,会触发 grunt 任务,将文件的串联版本构建到组件的 /dist
文件夹中。
父组件正在监视 /dist
文件夹中的更改,当子组件中的构建任务完成时,它会触发其任务在父应用中构建。
为了最大限度地减少父应用程序正在监视的文件数量,我们在所有 Bower 组件中使用前缀,因此监视配置如下所示:
watch: {
bower_components: {
files: ['./bower_components/orgname-*/dist/*.js'],
tasks: ['newer:copy']
}
}
我不知道这是否是公认的“最佳实践”,但它确实有效。
关于gruntjs - Grunt watch /Bower 链接 : What is the most appropriate way to use Grunt watch with Bower link when developing a bower component?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28242944/
在 Elastic Watcher 的官方网站上,他们说 Watcher 是 Elasticsearch 的插件,可根据数据的变化提供警报和通知 可以通过定期 Elasticsearch 查询 识别相
我有一个配置了 watch OS1 架构的项目。现在我想在同一个项目中只支持 watch OS2 架构。因此,为了在现有项目中仅配置 watch OS2,我删除了 watch OS1 的所有目标,包括
我想从我的 xcode 项目生成一个 .watchface 文件。有什么方法可以从默认 watch 应用程序之外创建 .watchface 文件吗? 我找到了一个网站Facer ,他们提供定制选项并从
我的手机在 Xcode 中被列为 ineligible target 并在旁边显示(没有配对的 Apple Watch)。 我的 Apple Watch 在 iOS 设备下注册。我可以看到UDID。
最近我在 gulp watch 上遇到错误,我用谷歌搜索并试图解决这个问题,但没有成功。有谁知 Prop 体原因吗? 应用程序基于 AngulerJs 1.3 并运行在 npm 5.7.1/node
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 4年前关闭。 Improve this questi
我有一个并发症,可能需要每 5 分钟更新一次。这很容易总结为每天 120 次更新。有没有办法只在用户唤醒 watch 时更新? 最佳答案 我认为您的问题的答案是否,目前没有办法只在用户唤醒 watch
有没有人有苹果 watch 在没有任何额外应用程序或集成设备的情况下生成的数据类型列表?它必须是 these 的子集,但我无法弄清楚哪些 最佳答案 数据类型的确切列表取决于型号,但最新的 Apple
在我的苹果 watch 扩展中,我想使用长按手势功能。是否有任何 api 等效于 UILongPressGestureRecognizer。我的要求是,在 watch 扩展上,我有表格想要长按单元格,
我一直在互联网上关注很多教程来学习如何设置并发症。按预期设置并发症我没有问题。 直到初始时间线条目过期。 12 小时后,我不知道如何更新它以保持并发症的存在。我将在下面分享我拥有的所有内容,希望有人可
今天几乎是偶然的,我偶然发现了索尼正在开放固件开发并在他们自己的引擎盖下创建一个项目的公告: http://developer.sonymobile.com/services/open-smartwa
目前用于语音听写的方法并不忙。使用的方法是“presentTextInputControllerWithSuggestions”。它遵循单个语音输入“VoiceInputButton -> Speak
我在获取 gulp-watch 时遇到问题或 gulp-watch-less在遵循记录的示例后触发。我最初解决的问题是lazypipe(此处未显示),但在我看来,我在使用插件的方式上做错了。这是我的简
我正在使用 Xcode 开发 Apple Watch 应用程序。我想在屏幕的左上角放置一些文本,与列出时间的位置相邻。 当我将标签向上拖动到屏幕的一部分时,它会自动向下对齐。 我看到大多数 Apple
我似乎找不到在哪里设置我的 Apple Watch 应用程序的产品名称。我确实看到了产品名称选项,但更新它没有任何作用。也看不到文档中的任何内容 最佳答案 为了让您的应用程序名称在 iPhone 上的
只是一个简单的问题。 选项和实例方法有什么区别? 基于 watch 示例,我们可以将 watcher 实现为一个选项( https://v3.vuejs.org/api/options-data.ht
是否可以设置count而不会触发 $watch打回来? $scope.count=1; $scope.$watch('count',function(){...}); 谢谢。 最佳答案 您可以使用 s
对于 sass 目前我正在使用 sass --watch path1:path2 将 scss 文件编译为 css 但我什至发现 compass watch path1:path2 还。这两款 wat
“事件”应用程序是否有 API?例如,我想从应用程序的“锻炼”部分检索信息(您燃烧的卡路里),我想检索您第一次打开应用程序时输入的个人信息。那可能吗?我如何检索这些信息? 最佳答案 没有专门针对事件应
有什么方法可以在 Apple Watch 上启用/配置 Wi-Fi 代理服务器吗? 我们想通过 Charles 测试一些东西,所以我们想将 Apple Watch 与 Charles 连接起来。 我没
我是一名优秀的程序员,十分优秀!