0.20.0 支持
这是我的幸运日。An aurelia-cli8小时后释放前说:
特点:支持捆绑版本号
Walkthru
首先,安装 0.20.0 并创建一个新应用程序。
npm install aurelia-cli@">=0.20.0" -g
au new my-app
或者,升级现有应用程序。
npm install aurelia-cli@">=0.20.0" --save-dev
接下来,打开my-app/aurelia-project/aurelia.json
.
Set the build.options.rev
属性为真。
"options": {
"minify": "stage & prod",
"sourcemaps": "dev & stage",
"rev": true
},
Set the output
and index
里面的属性build.targets
"targets": [
{
"id": "web",
"displayName": "Web",
"output": "scripts",
"index": "index.html"
}
],
The aurelia-cli
将寻找index
文件并替换引用scripts\vendor-bundle.js
像这样:
<script src="scripts\vendor-bundle.js" data-main="aurelia-bootstrapper">
<script src="scripts\vendor-bundle-947c308e28.js" data-main="aurelia-bootstrapper">
最后,构建应用程序。
au build --env prod
你的包看起来像这样:
app-bundle-e0c4d46f7d.js
vendor-bundle-dba9184d78.js
GitHub 上的源代码
cli/lib/build/bundler.js
let defaultBuildOptions = {
minify: "stage & prod",
sourcemaps: "dev & stage",
rev: false
};
cli/lib/build/bundler.js
if (buildOptions.rev) {
//Generate a unique hash based off of the bundle contents
this.hash = generateHash(concat.content);
bundleFileName = generateHashedPath(this.config.name, this.hash);
}