Skip to content

Commit

Permalink
refactor: use nodemon
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickJS committed Jan 8, 2016
1 parent 745d4d1 commit 8a958a2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 16 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ A minimal Angular 2 starter for Universal JavaScript using TypeScript and Webpac
## Installation

* `npm install --global typescript ts-node tsd webpack`
* `npm install --global typescript tsd webpack nodemon`
* `npm install`

## Serve

* `npm start` to build your client app and start a web server
* `npm run build` to prepare a distributable bundle

## Watch files
* `npm watch` to build your client app and start a web server

8 changes: 8 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ignore": [
"src/client.ts",
"dist"
],
"ext" : "js ts json html",
"legacy-watch": true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"zone.js": "0.5.10"
},
"devDependencies": {
"nodemon": "^1.8.1",
"ts-loader": "^0.7.2",
"ts-node": "^0.5.5",
"tsd": "^0.6.5",
"typescript": "^1.7.3",
"webpack": "^1.12.10",
Expand Down
9 changes: 4 additions & 5 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// polyfills
import * as path from 'path';
import * as express from 'express';
import * as universal from 'angular2-universal-preview';

// Angular 2
import {App} from './app/app';

Expand All @@ -13,16 +13,15 @@ app.engine('.ng2.html', universal.ng2engine);
app.set('views', __dirname);
app.set('view engine', 'ng2.html');

// static files
// Serve static files
app.use(express.static(root));


// Routes
app.use('/', (req, res) => {
res.render('index', { App });
});



// Server
app.listen(3000, () => {
console.log('Listen on http://localhost:3000');
});
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": true,
"target": "es5",
"module": "commonjs",
"removeComments": true,
Expand Down
21 changes: 13 additions & 8 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@ var webpackMerge = require('webpack-merge');
var path = require('path');

var common = {
context: process.cwd(),
output: {
publicPath: path.resolve(__dirname),
filename: 'bundle.js'
},
resolve: {
root: __dirname + '/src',
extensions: ['', '.ts', '.json', '.js']
},
module: {
Expand Down Expand Up @@ -60,10 +54,21 @@ var server = {
}
};

var defaults = {
context: process.cwd(),
resolve: {
root: __dirname + '/src'
},
output: {
publicPath: path.resolve(__dirname),
filename: 'bundle.js'
}
}

module.exports = [
// Client
webpackMerge({}, common, client),
webpackMerge({}, defaults, common, client),

// Server
webpackMerge({}, common, server)
webpackMerge({}, defaults, common, server)
]

0 comments on commit 8a958a2

Please sign in to comment.