Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 1b30589

Browse files
committed
Add angular material
1 parent 3ae6002 commit 1b30589

14 files changed

+110
-5
lines changed

WORKSPACE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ http_archive(
3535
sha256 = "72b0b4e517f43358f554c125e40e39f67688cd2738a8998b4a266981ed32f403",
3636
)
3737

38+
# Angular material
39+
http_archive(
40+
name = "angular_material",
41+
url = "https://github.com/gregmagolan/material2/archive/366b076bc46f08218a8019de060fbed20312395c.zip",
42+
strip_prefix = "material2-366b076bc46f08218a8019de060fbed20312395c",
43+
)
44+
3845
# Rules for compiling sass
3946
http_archive(
4047
name = "io_bazel_rules_sass",
@@ -97,3 +104,7 @@ sass_repositories()
97104
load("@angular//:index.bzl", "ng_setup_workspace")
98105

99106
ng_setup_workspace()
107+
108+
load("@angular_material//:index.bzl", "mat_setup_workspace")
109+
110+
mat_setup_workspace()

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111
"zone.js": "0.8.26"
1212
},
1313
"devDependencies": {
14+
"@angular/animations": "7.0.1",
1415
"@angular/bazel": "7.0.1",
16+
"@angular/cdk": "7.0.1",
1517
"@angular/compiler": "7.0.1",
1618
"@angular/compiler-cli": "7.0.1",
19+
"@angular/common": "7.0.1",
1720
"@angular/core": "7.0.1",
21+
"@angular/material": "7.0.1",
1822
"@bazel/benchmark-runner": "0.1.0",
1923
"@bazel/ibazel": "0.5.0",
2024
"@bazel/karma": "0.20.3",

src/BUILD.bazel

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ng_module(
1818
tsconfig = ":tsconfig.json",
1919
deps = [
2020
"//src/hello-world",
21+
"//src/material",
2122
"//src/todos",
2223
"@angular//packages/core",
2324
"@angular//packages/router",
@@ -35,19 +36,22 @@ ts_devserver(
3536
additional_root_paths = [
3637
"npm/node_modules/zone.js/dist",
3738
"npm/node_modules/tslib",
39+
"npm/node_modules/@angular/material/prebuilt-themes",
3840
"npm/node_modules/@ngrx/store/bundles",
3941
],
4042
# Start from the development version of the main
4143
entry_module = "angular_bazel_example/src/main.dev",
4244
scripts = [
4345
":require.config.js",
46+
":module-id.js",
4447
],
4548
# This is the URL we'll point our <script> tag at
4649
serving_path = "/bundle.min.js",
4750
# Serve these files in addition to the JavaScript bundle
4851
static_files = [
4952
"@npm//node_modules/zone.js:dist/zone.min.js",
5053
"@npm//node_modules/tslib:tslib.js",
54+
"@npm//node_modules/@angular/material:prebuilt-themes/deeppurple-amber.css",
5155
"@npm//node_modules/@ngrx/store:bundles/store.umd.min.js",
5256
"index.html",
5357
],
@@ -93,13 +97,22 @@ genrule(
9397
cmd = "cp $< $@",
9498
)
9599

100+
# See comment for zonejs above
101+
genrule(
102+
name = "copy_material_theme",
103+
srcs = ["@npm//node_modules/@angular/material:prebuilt-themes/deeppurple-amber.css"],
104+
outs = ["deeppurple-amber.css"],
105+
cmd = "cp $< $@",
106+
)
107+
96108
load("@build_bazel_rules_nodejs//:defs.bzl", "history_server")
97109

98110
history_server(
99111
name = "prodserver",
100112
data = [
101113
"index.html",
102114
":bundle",
115+
":copy_material_theme",
103116
":copy_systemjs",
104117
":copy_zonejs",
105118
],

src/app.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
<mat-toolbar>
2+
<span>My Application</span>
3+
</mat-toolbar>
14
<nav><a routerLink="/">Home</a> | <a routerLink="/todos">Todos</a></nav>
25
<router-outlet></router-outlet>

src/app.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import {StoreModule} from '@ngrx/store';
55

66
import {AppRoutingModule} from './app-routing.module';
77
import {AppComponent} from './app.component';
8+
import {MaterialModule} from './material/material.module';
89
import {todoReducer} from './reducers/reducers';
910

1011
@NgModule({
1112
declarations: [AppComponent],
12-
imports: [BrowserModule, AppRoutingModule, StoreModule.forRoot({todoReducer})],
13+
imports: [AppRoutingModule, BrowserModule, MaterialModule, StoreModule.forRoot({todoReducer})],
1314
exports: [AppComponent],
1415
bootstrap: [AppComponent],
1516
})

src/hello-world/BUILD.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ ng_module(
2020
":hello-world.component.html",
2121
":hello-world-styles",
2222
],
23+
tsconfig = "//src:tsconfig.json",
2324
deps = [
2425
"//src/lib",
26+
"//src/material",
2527
"@angular//packages/core",
2628
"@angular//packages/forms",
2729
"@angular//packages/router",
28-
"@npm//@types",
2930
],
3031
)
3132

@@ -51,6 +52,7 @@ ts_web_test_suite(
5152
bootstrap = [
5253
"@npm//node_modules/zone.js:dist/zone-testing-bundle.js",
5354
"@npm//node_modules/reflect-metadata:Reflect.js",
55+
"//src:module-id.js",
5456
],
5557
browsers = [
5658
"@io_bazel_rules_webtesting//browsers:chromium-local",

src/hello-world/hello-world.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ <h1>Home</h1>
33
<div>Hello {{ name }}</div>
44

55
<input type="text" [(ngModel)]="name"/>
6+
7+
<div><mat-icon>mood</mat-icon></div>

src/hello-world/hello-world.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import {NgModule} from '@angular/core';
22
import {FormsModule} from '@angular/forms';
33
import {RouterModule} from '@angular/router';
4+
import {MaterialModule} from '../material/material.module';
45

56
import {HelloWorldComponent} from './hello-world.component';
67

78
@NgModule({
89
declarations: [HelloWorldComponent],
910
imports: [
10-
FormsModule, RouterModule, RouterModule.forChild([{path: '', component: HelloWorldComponent}])
11+
FormsModule, RouterModule, MaterialModule,
12+
RouterModule.forChild([{path: '', component: HelloWorldComponent}])
1113
],
1214
exports: [HelloWorldComponent],
1315
})

src/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<head>
55
<title>Angular Bazel Example</title>
66
<base href="/">
7+
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
8+
<link href="/deeppurple-amber.css" rel="stylesheet">
79
</head>
810
<body>
911
<!-- The Angular application will be bootstrapped into this element. -->

src/material/BUILD.bazel

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
load("@angular//:index.bzl", "ng_module")
4+
5+
ng_module(
6+
name = "material",
7+
srcs = glob(["*.ts"]),
8+
tsconfig = "//src:tsconfig.json",
9+
deps = [
10+
"@angular//packages/core",
11+
"@angular_material//src/lib:material",
12+
],
13+
)

src/material/material.module.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {NgModule} from '@angular/core';
2+
import {MatIconModule, MatToolbarModule} from '@angular/material';
3+
4+
const matModules = [MatToolbarModule, MatIconModule];
5+
6+
@NgModule({
7+
imports: matModules,
8+
exports: matModules,
9+
})
10+
export class MaterialModule {
11+
}

src/module-id.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Work-around for angular material issue with ts_devserver and ts_web_test_suite.
2+
// Material requires `module.id` to be valid. This symbol is valid in the production
3+
// bundle but not in ts_devserver and ts_web_test_suite.
4+
// See https://github.com/angular/material2/issues/13883.
5+
// TODO(gmagolan): remove this work-around once #13883 is resolved.
6+
var module = {id: ''};

src/todos/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ng_module(
2020
"todos.component.html",
2121
":todos-styles",
2222
],
23+
tsconfig = "//src:tsconfig.json",
2324
deps = [
2425
"//src/lib",
2526
"//src/reducers",
@@ -28,7 +29,6 @@ ng_module(
2829
"@angular//packages/forms",
2930
"@angular//packages/router",
3031
"@npm//@ngrx/store",
31-
"@npm//@types",
3232
"@rxjs",
3333
],
3434
)

yarn.lock

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
# yarn lockfile v1
33

44

5+
"@angular/[email protected]":
6+
version "7.0.1"
7+
resolved "https://registry.yarnpkg.com/@angular/animations/-/animations-7.0.1.tgz#2df561c0959e156985297e69b7c30614537b4ffe"
8+
integrity sha512-gRirN4Maduh198VhpI1cLoWCtD/BTQT4lPuwiVkHYaradiwEqPlyE+EP/4QZRmFZH+BqwvjS+FYtICznE668Cg==
9+
dependencies:
10+
tslib "^1.9.0"
11+
512
"@angular/[email protected]":
613
version "7.0.1"
714
resolved "https://registry.yarnpkg.com/@angular/bazel/-/bazel-7.0.1.tgz#42e1a114a20643ea53cff1bb8091e1ba08637885"
@@ -12,6 +19,22 @@
1219
shelljs "0.8.2"
1320
tsickle "0.32.1"
1421

22+
"@angular/[email protected]":
23+
version "7.0.1"
24+
resolved "https://registry.yarnpkg.com/@angular/cdk/-/cdk-7.0.1.tgz#8c991a2399c6a89c7238fa9ce1d0623e243b3787"
25+
integrity sha512-WCIz2kbNMrEXkGxbHfBMRvjH7sxzp+nBR2gEhBvUEm9Ap/wBIJaTnHOF743D2fEhtW3IgpaYsTDTKiVryOFcQg==
26+
dependencies:
27+
tslib "^1.7.1"
28+
optionalDependencies:
29+
parse5 "^5.0.0"
30+
31+
"@angular/[email protected]":
32+
version "7.0.1"
33+
resolved "https://registry.yarnpkg.com/@angular/common/-/common-7.0.1.tgz#55750879f08d5f4b6f247f7dce0b5ea2b3ec2059"
34+
integrity sha512-QnGwwM6+OLuzu0VZvzQMPENJQgOMmcjZC1vxWu5y62fPI3BsTDYaePOAEN6mfY8R09J90FmF2IXXC5DN/el0Ug==
35+
dependencies:
36+
tslib "^1.9.0"
37+
1538
"@angular/[email protected]":
1639
version "7.0.1"
1740
resolved "https://registry.yarnpkg.com/@angular/compiler-cli/-/compiler-cli-7.0.1.tgz#bd21ebc950f65fb5848307a271e7bd9d049efc9c"
@@ -42,6 +65,13 @@
4265
dependencies:
4366
tslib "^1.9.0"
4467

68+
"@angular/[email protected]":
69+
version "7.0.1"
70+
resolved "https://registry.yarnpkg.com/@angular/material/-/material-7.0.1.tgz#51ddbc1ae7ed41926fd8a0cbba0f7565ee8fda2d"
71+
integrity sha512-/gf2G+/W/SB/54Q+EDKWfaDFuj403XYMSY3IcFJmuR4H8KkDtDr6bM9/HrRpYWNIlrVwOrKE9ByeoFzm5yDmvA==
72+
dependencies:
73+
tslib "^1.7.1"
74+
4575
4676
version "0.1.0"
4777
resolved "https://registry.yarnpkg.com/@bazel/benchmark-runner/-/benchmark-runner-0.1.0.tgz#a586394fcf7f2402b381319fbc2750627b5a06f1"
@@ -3074,6 +3104,11 @@ parse-json@^2.2.0:
30743104
dependencies:
30753105
error-ex "^1.2.0"
30763106

3107+
parse5@^5.0.0:
3108+
version "5.1.0"
3109+
resolved "https://registry.yarnpkg.com/parse5/-/parse5-5.1.0.tgz#c59341c9723f414c452975564c7c00a68d58acd2"
3110+
integrity sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==
3111+
30773112
30783113
version "0.0.5"
30793114
resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d"
@@ -4198,7 +4233,7 @@ [email protected]:
41984233
source-map "^0.6.0"
41994234
source-map-support "^0.5.0"
42004235

4201-
[email protected], tslib@^1.8.1, tslib@^1.9.0:
4236+
[email protected], tslib@^1.7.1, tslib@^1.8.1, tslib@^1.9.0:
42024237
version "1.9.3"
42034238
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
42044239
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==

0 commit comments

Comments
 (0)