Skip to content

Commit 78c2159

Browse files
committed
basic bootstrap
1 parent 7fcd969 commit 78c2159

File tree

11 files changed

+69
-43
lines changed

11 files changed

+69
-43
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ I'm using [dockie/lamp](http://github.com/robloach/dockie)
2323
2424
4. Copy last [wordpress CMS](https://wordpress.org/download/) to `www` folder
2525
26+
5. Build js and css
27+
```
28+
$ npm run build
29+
```
30+
2631
**Backend stack**
2732
2833
* [Dockie](../dockie)

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"start": "npm run watch",
88
"watch": "webpack --watch --progress --profile",
9-
"build": "webpack --progress --profile --bail",
9+
"build": "webpack --progress --profile",
1010
"test": "echo \"Error: no test specified\" && exit 1"
1111
},
1212
"repository": {
@@ -19,7 +19,7 @@
1919
"angular"
2020
],
2121
"author": "Artem Demo",
22-
"license": "ISC",
22+
"license": "MIT",
2323
"bugs": {
2424
"url": "https://github.com/artemdemo/wordpress-restapi-angular2/issues"
2525
},
@@ -47,11 +47,15 @@
4747
"reflect-metadata": "^0.1.10",
4848
"rxjs": "^5.3.0",
4949
"style-loader": "^0.16.1",
50+
"ts-helpers": "^1.1.2",
5051
"ts-loader": "^2.0.3",
5152
"typescript": "^2.2.2",
5253
"url-loader": "^0.5.8",
5354
"webpack": "^2.3.3",
5455
"zone.js": "^0.8.5"
5556
},
56-
"devDependencies": {}
57+
"devDependencies": {
58+
"@types/requirejs": "^2.1.29",
59+
"to-string-loader": "^1.1.5"
60+
}
5761
}

source/app/app.component.html

Lines changed: 0 additions & 14 deletions
This file was deleted.

source/app/app.component.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
import { Component } from '@angular/core';
22

33
@Component({
4-
selector: 'my-app', // <my-app></my-app>
5-
templateUrl: './app.component.html',
4+
selector: 'wp-app',
5+
template: `
6+
<header>
7+
<nav>
8+
<a [routerLink]="['']">Home</a>
9+
<a [routerLink]="['about']">About</a>
10+
</nav>
11+
</header>
12+
<main>
13+
<h1>Hello!</h1>
14+
15+
<router-outlet></router-outlet>
16+
</main>
17+
`,
618
})
719
export class AppComponent {
820
constructor() {

source/app/app.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { BrowserModule } from '@angular/platform-browser';
33
import { HttpModule } from '@angular/http';
44
import { FormsModule } from '@angular/forms';
55

6-
// import { ApiService } from './shared';
76
import { AppComponent } from './app.component';
87
import { HomeView } from '../views/home.view';
98
import { routing } from './app.routing';
@@ -22,6 +21,6 @@ import { routing } from './app.routing';
2221
providers: [],
2322
bootstrap: [AppComponent]
2423
})
25-
export class AppModule {
24+
export default class AppModule {
2625
constructor(public appRef: ApplicationRef) {}
2726
}

source/index.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
/// <reference path="../node_modules/@types/requirejs/index.d.ts" />
2+
13
//import { enableProdMode } from '@angular/core';
4+
import 'ts-helpers';
5+
import 'reflect-metadata';
6+
import 'core-js/client/shim';
7+
import 'zone.js';
28
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3-
import { AppModule } from './app/app.module';
9+
import AppModule from './app/app.module';
410

511
// depending on the env mode, enable prod mode or add debugging modules
612
// if (ENV.production === 'production') {
@@ -11,8 +17,10 @@ export function main() {
1117
return platformBrowserDynamic().bootstrapModule(AppModule);
1218
}
1319

14-
if (document.readyState === 'complete') {
15-
main();
16-
} else {
17-
document.addEventListener('DOMContentLoaded', main);
18-
}
20+
main();
21+
22+
// if (document.readyState === 'complete') {
23+
// main();
24+
// } else {
25+
// document.addEventListener('DOMContentLoaded', main);
26+
// }

source/views/home.view.html

Lines changed: 0 additions & 3 deletions
This file was deleted.

source/views/home.view.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ import { Component, OnInit } from '@angular/core';
22

33
@Component({
44
selector: 'home-view',
5-
templateUrl: './home.view.html',
6-
styleUrls: ['./home.view.less']
5+
styles: [require('./home.view.less')],
6+
template: `
7+
<p>
8+
Home Works!
9+
</p>
10+
`,
711
})
812
export class HomeView implements OnInit {
913

theme/index.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
<meta name="description" content="<?php bloginfo( 'description' ); ?>" />
1313
<link href="<?php echo get_template_directory_uri(); ?>/css/styles.css" rel="stylesheet" type="text/css" />
1414
<script async src="<?php echo get_template_directory_uri(); ?>/js/bundle.js"></script>
15+
16+
<base href="/">
1517
</head>
1618
<body>
1719

18-
<wp-app>Loading...</wp-app>
20+
<wp-app>Loading...!!</wp-app>
1921

2022
</body>
2123
</html>

webpack.config.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const HtmlWebpackPlugin = require('html-webpack-plugin');
22
const CopyWebpackPlugin = require('copy-webpack-plugin');
33
const ExtractTextPlugin = require('extract-text-webpack-plugin');
4-
const path = require('path');
54
const CleanWebpackPlugin = require('clean-webpack-plugin');
65
const ContextReplacementPlugin = require('webpack').ContextReplacementPlugin;
76
const DefinePlugin = require('webpack').DefinePlugin;
7+
const path = require('path');
88

99
const isProduction = process.env.NODE_ENV === 'production';
1010

@@ -29,12 +29,8 @@ module.exports = {
2929
exclude: /node_modules/,
3030
},
3131
{
32-
test: /\.(less|css)$/,
33-
use: [
34-
'style-loader',
35-
{ loader: 'css-loader', options: { importLoaders: 1 } },
36-
'less-loader'
37-
]
32+
test: /\.(css|less)$/,
33+
loaders: ['to-string-loader', 'css-loader', 'less-loader'],
3834
},
3935
{test: /\.(png|gif|jpg)(\?.*$|$)/, loader: 'url-loader?limit=100000&name=images/[hash].[ext]'},
4036
{test: /\.(json)(\?.*$|$)/, loader: 'json-loader'},
@@ -55,7 +51,6 @@ module.exports = {
5551
new ExtractTextPlugin('./css/styles.css'),
5652

5753
new CleanWebpackPlugin([
58-
'./theme/js',
5954
'./www/wp-content/themes/restapi-angular'
6055
], {
6156
verbose: true,

0 commit comments

Comments
 (0)