@angularclass/conventions-loader

中文文档
1.0.13发布于 2016/11/07Apache-2.0CommonJS近 30 天下载 3779

Allow default for @Component metadata for Angular 2

原始使用文档

Angular 2 Fundamentals


Angular 2 Conventions Loader

Allow defaults for @Component metadata for Angular 2

npm install @angularclass/conventions-loader --save-dev loader options

// default values
selectorPrefix = '';
cssExtension   = '.css';
htmlExtension  = '.html';
'-component' is removed from selector generated by className
{
  test: /\.ts$/,
  loaders: [
    'ts-loader',
    '@angularclass/conventions-loader'
  ]
},

Given this simple Component example app.js

@Component({})
export class App {
}

Webpack will change the code app.js

@Component({
  selector: "app",
  styles: [require("./app.css")],
  template: require("./app.html")
})
export class App {
}

this is assuming you have corresponding files next to the component. You may overwrite the selector at anytime by providing one. If the selector and the component file name does not match then the corresponding css/template file with the selector will be injected.

Credits

Sean Larkin from the Webpack team TheLarkInn/angular2-template-loader


enjoy — AngularClass



AngularClass ##AngularClass

Learn AngularJS, Angular 2, and Modern Web Development from the best. Looking for corporate Angular training, want to host us, or Angular consulting? [email protected]


Apache-2.0

版本与发布记录

@angularclass/conventions-loader 共发布 14 个版本,首次发布于 2016/07/31;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.13latest2016/11/079 年前
1.0.122016/08/2010 年前
1.0.112016/08/2010 年前
1.0.102016/08/1310 年前
1.0.92016/08/1110 年前
1.0.82016/08/1010 年前

关于 @angularclass/conventions-loader 的常见问题

@angularclass/conventions-loader 是什么?

Allow default for @Component metadata for Angular 2

如何安装 @angularclass/conventions-loader?

在项目目录运行 npm install @angularclass/conventions-loader,或使用 pnpm add / yarn add / bun add。

@angularclass/conventions-loader 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/angularclass__conventions-loader 是否存在。

@angularclass/conventions-loader 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@angularclass/conventions-loader 可以商用吗?

@angularclass/conventions-loader 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@angularclass/conventions-loader 的下载量有多少?

根据 npm 官方下载统计,@angularclass/conventions-loader 在 2026/10/06 – 2026/11/04 这 30 天内被下载 3,779 次,日均约 126 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@angularclass/conventions-loader 还在维护吗?

最新版本 1.0.13 发布于 2016/11/07(9 年前);至今共发布 14 个版本,其中过去 12 个月发布了 0 个;首次发布于 2016/07/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。