我正在使用angular-cli创建一个库项目。按照angular文档的说明,我最终得到了一个./root/src/app文件夹,可以在其中放置一个测试应用程序来演示我的库的功能,以及一个./root/projects/library-name包含我的库功能的文件夹。
现在,如果我./root/src/app要导入模块/组件/类等,则angular-cli allready已使用键/值路径配置为我设置了tsconfig.json。
{
"compilerOptions": {
"paths": {
"my-library/*": [
"dist/my-library/*"
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
对于./root/src/app模仿我们的库作为node_module安装的所有目的。
因此,即使将库构建为./root/dist/library-name,以下代码也可以在我的测试应用程序中很好地工作:
import { MyLibraryModule } from 'library-name';
Run Code Online (Sandbox Code Playgroud)
问题
SCSS与tsconfig.json中描述的规则不同。如果我的库中包含一些我希望对我的lib用户开放的scss,我可以做到。安装我的库的每个人都可以通过
@import '~library-name/scss';
Run Code Online (Sandbox Code Playgroud)
但我的测试应用程序无法。
题
如何angular.json以某种方式配置我的scss预处理程序配置,使其模仿我的tsconfig.json,但是对scss 进行了angular-cli ?换一种说法; 如何配置angular-cli为我的库构建输出设置目录别名?
编辑只是为了澄清,一旦库发布,我的scss就可以访问了。当它被其他应用程序使用时没问题。我的问题是到达./root/src/app测试应用程序中已发布的scss 。
我在开发环境中的应用程序在启动阶段非常缓慢。我在各个地方设置了一些调试日志,以查看花费了很多时间,并且发现我main.ts实际上花了将近9分钟的时间 才app.module导入我的!
资源
import { performance } from 'perf_hooks';
const startTime = performance.now();
import { Log } from 'api/common/util/logger/log';
Log.log.info(`??????????????????????????????????????????????????????????????`);
Log.log.info(`? Starting: ${new Date().toISOString()} ?`);
Log.log.info(`??????????????????????????????????????????????????????????????`);
// From here -------------------->
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import 'reflect-metadata';
import { existsSync, mkdirSync, writeFile } from 'fs';
import * as express from 'express';
import * as bodyParser from 'body-parser';
import * as helmet from 'helmet';
import * as morgan from …Run Code Online (Sandbox Code Playgroud) 我正在尝试优化我的 azure devops 管道中的构建时间,但npm install我的 dockerfile 中的阶段不会缓存。为什么?
这是我的 dockerfile。在复制我的其余源代码之前,我已经将 package*.json 文件和 npm install 分开复制到它自己的层中,因为这是最佳实践,并且应该使 npm install 层可以在构建之间缓存。
FROM node:12-alpine3.12 AS builder
WORKDIR /app
ARG VERSION
COPY package.json ./
COPY package-lock.json ./
RUN npm install
COPY . .
RUN npm run build
...
FROM node:12-alpine3.12
COPY --from=builder /dist .
...
Run Code Online (Sandbox Code Playgroud)
这是我的构建管道。由于 Azure 每次都构建在干净的 vm 上,因此我尝试下拉现有图像以利用以前的构建缓存(参考:如何在 Azure DevOps 中启用 Docker 层缓存)。
FROM node:12-alpine3.12 AS builder
WORKDIR /app
ARG VERSION
COPY package.json ./
COPY package-lock.json ./
RUN npm install …Run Code Online (Sandbox Code Playgroud) 我试图找出在控制器/指令之间共享属性或状态的"首选"或"角度方式".有几种方法可以实现这一点,但我希望保持最佳实践.以下是一些如何实现此功能的平庸示例:
1.使用$ scope.$ watch
// The parent controller/scope
angular.module('myModule').controller('parentController', ['$scope', function($scope) {
$scope.state = {
myProperty: 'someState'; // Default value to be changed by some DOM element
};
}]);
// The child controller/scope.
angular.module('myModule').controller('childController', ['$scope', function($scope) {
$scope.$watch('state.myProperty', function (newVal) {
// Do some action here on state change
});
}]);
Run Code Online (Sandbox Code Playgroud)
编辑:根据下面的答案,这是不好的做法,应该避免.它是不可测试的并且放置了不需要的DOM依赖性.
2.使用$ broadcast
// The parent controller
angular.module('myModule').controller('parentController', ['$scope', function($scope) {
var myProperty = 'someState';
$scope.setState = function (state) {
myProperty = state; // Set by some other …Run Code Online (Sandbox Code Playgroud) 以下用于在Spring 1.5.10.RELEASE中工作,但在Spring 2.0.7.RELEASE中不起作用,我不知道为什么:
实体
@Entity
@Table(name = "locations")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Location {
// ... unimportant stuff
@Column(name = "c_locations_id")
private String cLocationId;
// ... more unimportant stuff
}
Run Code Online (Sandbox Code Playgroud)
存储库(又名"问题")
@Repository
public interface LocationRepository extends JpaRepository<Location, Long>, JpaSpecificationExecutor<Location> {
Location findByCLocationId(String cLocationId);
List<Location> findAllByOrderByCLocationIdAsc();
}
Run Code Online (Sandbox Code Playgroud)
我在上面的代码的Spring 2.0.7.RELEASE下得到的错误是
java.lang.IllegalArgumentException:无法在此ManagedType上找到具有给定名称[CLocationId]的Attribute.
由于其他情况,我无法更改属性的名称,因此我尝试了存储库中方法的不同变体:
findBycLocationId - 找不到类型为Location的属性orderBycLocationIdAsc!findByClocationId - 找不到类型位置的属性clocationId!你是说'CLocationId','cLocationId'吗?findByCLocationId - 无法在此ManagedType上找到具有给定名称[CLocationId]的Attribute它想要什么?!我只是想升级框架......
我已遍历堆栈溢出,并且没有找到有关如何返回结果集中包含的正确分页数据的任何信息.
我正在尝试从我的mongo商店聚合一些数据.我想要的是回报:
{
total: 5320,
page: 0,
pageSize: 10,
data: [
{
_id: 234,
currentEvent: "UPSTREAM_QUEUE",
events: [
{ ... }, { ... }, { ... }
]
},
{
_id: 235,
currentEvent: "UPSTREAM_QUEUE",
events: [
{ ... }, { ... }, { ... }
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止:
// page and pageSize are variables
db.mongoAuditEvent.aggregate([
// Actual grouped data
{"$group": {
"_id" : "$corrId",
"currentEvent": {"$last": "$event.status"},
"events": { $push: "$$ROOT"}
}},
// Pagination group
{"$group": {
"_id": …Run Code Online (Sandbox Code Playgroud) 我不确定这是否可以在没有javascript的情况下完成,但我希望它有一个解决方案.考虑一下这个小提琴:http://jsfiddle.net/PPeYH/
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.content {
border: 1px solid;
min-height: 3em;
}
.container {
max-width: 600px;
margin: 0 auto;
overflow: hidden;
clear: both;
}
#placeholder-body {
position: relative;
border: 0;
}
.split-tile {
float: left;
}
.split-left {
width: 60%;
}
.split-left .content {
margin-left: auto;
margin-right: 0;
max-width: 360px;
}
.split-right {
width: 40%;
}
.split-right .content {
margin-left: 0;
margin-right: auto;
max-width: 240px;
}
Run Code Online (Sandbox Code Playgroud)
<div><div class="content container">Header</div></div>
<div id="placeholder-body"> …Run Code Online (Sandbox Code Playgroud) typescript ×2
angular ×1
angularjs ×1
azure-devops ×1
css ×1
docker ×1
dockerfile ×1
html ×1
java ×1
mongodb ×1
nestjs ×1
node.js ×1
pagination ×1
sass ×1
spring ×1
ts-node ×1