安裝jspm命令行界面。 jspm是客戶端依賴項的包管理器。閱讀它...這很棒。
npm install jspm -g
爲該項目創建一個文件夾。
mkdir minimal
cd minimal
初始化JSPM客戶包管理... 接受所有默認設置,除了使用巴別transpiler選項(VS Traceur)
jspm init
啓用所有花哨通過添加以下行切削刃巴貝爾善在你的config.js的babelOptions(jspm init
創建config.js文件):
System.config({
defaultJSExtensions: true,
transpiler: "babel",
babelOptions: {
"stage": 0, <------ add this to turn on the hotness
"optional": [
"runtime"
]
},
...
安裝奧裏利亞
jspm install aurelia-framework
jspm install aurelia-bootstrapper
創建一個index.html,使用SystemJS加載程序(jspm的模塊加載程序對應部分)啓動Aurelia。
<!doctype html>
<html>
<head>
<title>Aurelia</title>
</head>
<body aurelia-app>
<h1>Loading...</h1>
<script src="jspm_packages/system.js"></script>
<script src="config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
當奧裏利亞自舉這將尋找一個默認視圖和視圖模型...創建它們:
app.js
export class App {
message = 'hello world';
}
應用。HTML
<template>
${message}
</template>
安裝杯和瀏覽器同步服務中的文件:
npm install gulp
npm install --save-dev browser-sync
添加gulpfile.js
var gulp = require('gulp');
var browserSync = require('browser-sync');
// this task utilizes the browsersync plugin
// to create a dev server instance
// at http://localhost:9000
gulp.task('serve', function(done) {
browserSync({
open: false,
port: 9000,
server: {
baseDir: ['.'],
middleware: function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
next();
}
}
}, done);
});
啓動Web服務器。
gulp serve
瀏覽到應用程序:
http://localhost:9000
完成。
這是你的項目結構將是什麼,你就完蛋了的時候,如:
注:這僅僅是一個快速和骯髒的設置。這不一定是推薦的文件夾結構,並且加載器使用babel來即時傳輸js文件。您需要根據您的需求進行微調。這裏的目的是向你展示如何以儘可能少的步驟起牀和跑步。
如何將另一個npm軟件包添加到像aurelia這樣的項目中?例如,我一直在嘗試集成tumblr.js api,但我似乎無法從我的任何模塊訪問它 – Felipe
新的jspm版本堵塞了所有東西 - 我將在整理後更新本指南 –
已aurlelia開發人員解決了這個問題?一個人應該如何用簡單的設置開始一個新項目? – northamerican