diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e717f5e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore index 2d2b47d..17a4d72 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ .idea -node_modules \ No newline at end of file +node_modules +src/**.js +src/**.js.map +typings diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..449691b --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +save-exact=true \ No newline at end of file diff --git a/README.md b/README.md index d09f403..1209905 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,15 @@ Angular 1 Scaffold by ngParty team. +## Install + +```bash +$ npm install +``` + +## Start Development + +```bash +$ npm start +``` + diff --git a/package.json b/package.json index fad29f0..127c987 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,18 @@ "version": "1.0.0", "description": "Angular 1 scaffold with Typescript and ng-metadata", "main": "app/app.js", - "scripts": {}, + "config": { + "port": "9000" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/ngParty/Angular1-scaffold.git" + }, + "scripts": { + "typings": "typings install", + "postinstall": "npm run typings", + "start": "webpack-dev-server --port $npm_package_config_port --hot --inline --progress --profile --colors --watch --display-error-details --display-cached --content-base src/" + }, "keywords": [], "contributors": [ "Martin Hochel ", @@ -11,7 +22,16 @@ ], "license": "ISC", "dependencies": { + "angular": "1.5.0", + "ng-metadata": "1.0.0" }, "devDependencies": { + "copy-webpack-plugin": "1.1.1", + "html-webpack-plugin": "2.9.0", + "ts-loader": "0.8.1", + "typescript": "1.7.5", + "typings": "0.6.8", + "webpack": "1.12.13", + "webpack-dev-server": "1.14.1" } } diff --git a/src/app/app.component.ts b/src/app/app.component.ts new file mode 100644 index 0000000..7615e84 --- /dev/null +++ b/src/app/app.component.ts @@ -0,0 +1,9 @@ +import { Component } from 'ng-metadata/core'; + +@Component({ + selector: `app`, + template: ` +

Hello from Pluto!!!

+ ` +}) +export class AppComponent{} diff --git a/src/app/app.ts b/src/app/app.ts new file mode 100644 index 0000000..55e8329 --- /dev/null +++ b/src/app/app.ts @@ -0,0 +1,9 @@ +import * as angular from 'angular'; +import { provide } from 'ng-metadata/core'; + +import { AppComponent } from './app.component.ts'; + +const ngModule = angular.module( 'app', [] ) + .directive( ...provide( AppComponent ) ); + +export const AppModule = ngModule; diff --git a/src/bootstrap.ts b/src/bootstrap.ts new file mode 100644 index 0000000..ad31479 --- /dev/null +++ b/src/bootstrap.ts @@ -0,0 +1,4 @@ +import { bootstrap } from 'ng-metadata/platform'; +import { AppModule } from './app/app'; + +bootstrap( AppModule ); diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..c4d24cd --- /dev/null +++ b/src/index.html @@ -0,0 +1,41 @@ + + + + + <%= htmlWebpackPlugin.options.title %> + + + + + + + + + + + + Loading... + + +<% if (htmlWebpackPlugin.options.googleAnalytics) { %> + +<% } %> + +<% if (htmlWebpackPlugin.options.env === 'development') { %> + + +<% } %> + + + diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..f293ee1 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": true, + "experimentalDecorators": true, + "moduleResolution": "node" + }, + "exclude": [ + "node_modules", + "typings/main", + "typings/main.d.ts" + ] +} diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..f52a562 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,74 @@ +const webpack = require( 'webpack' ); + +const CopyWebpackPlugin = require( 'copy-webpack-plugin' ); +const HtmlWebpackPlugin = require( 'html-webpack-plugin' ); + +const ENV = process.env.ENV = process.env.NODE_ENV = 'development'; + +const webpackConfigEntryPoints = { + app: './src/bootstrap.ts' +}; + +const webpackConfigLoaders = [ + + // Scripts + { + test: /\.ts$/, + exclude: [ /node_modules/ ], + loader: 'ts-loader' + }, + + // Styles + { + test: /\.scss$/, + loaders: [ 'style', 'css', 'sass' ] + } + +]; + +const webpackConfigPlugins = [ + + new HtmlWebpackPlugin({ + title: 'Tombaugh Regio', + template: 'src/index.html', + env: ENV, + host: '0.0.0.0', + port: process.env.npm_package_config_port, + googleAnalytics: { + trackingId: 'UA-XXXX-XX' + } + }), + + new CopyWebpackPlugin([ + { + from: 'src/assets', + to: './' + } + ]) + + // // Load lodash into global + // new webpack.ProvidePlugin( { + // lodash: 'lodash' + // } ) + +]; + + +module.exports = { + devtool: 'source-map', + entry: webpackConfigEntryPoints, + output: { + path: '/', + publicPath: '/', + filename: '[name].js' + }, + resolve: { + // Add `.ts` as a resolvable extension. + extensions: [ '', '.webpack.js', '.web.js', '.ts', '.js' ] + }, + watch: true, + module: { + loaders: webpackConfigLoaders + }, + plugins: webpackConfigPlugins +};