Skip to content

Commit f4b4034

Browse files
committed
Merge pull request #548 from floreks/icons-offline
Integrate material icons and roboto fonts with gulp build pipeline
2 parents d061979 + 260c984 commit f4b4034

File tree

4 files changed

+70
-25
lines changed

4 files changed

+70
-25
lines changed

bower.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@
99
"angular-messages": "~1.5.0",
1010
"angular-ui-router": "~0.2.15",
1111
"angular-resource": "~1.5.0",
12-
"angular-sanitize": "~1.5.0"
12+
"angular-sanitize": "~1.5.0",
13+
"material-design-icons": "~2.2.2",
14+
"roboto-fontface": "~0.4.5"
15+
},
16+
"overrides": {
17+
"material-design-icons": {
18+
"main": "iconfont/material-icons.css"
19+
},
20+
"roboto-fontface": {
21+
"main": "css/roboto-fontface.css"
22+
}
1323
},
1424
"devDependencies": {
1525
"angular-mocks": "~1.5.0",

build/build.js

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,17 @@ gulp.task('build:cross', ['backend:prod:cross', 'build-frontend:cross']);
4343
/**
4444
* Builds production version of the frontend application for the current architecture.
4545
*/
46-
gulp.task('build-frontend', ['assets', 'index:prod', 'clean-dist'], function() {
46+
gulp.task('build-frontend', ['fonts', 'icons', 'assets', 'index:prod', 'clean-dist'], function() {
4747
return buildFrontend(conf.paths.distPublic);
4848
});
4949

5050
/**
5151
* Builds production version of the frontend application for all architecures.
5252
*/
53-
gulp.task('build-frontend:cross', ['assets:cross', 'index:prod', 'clean-dist'], function() {
54-
return buildFrontend(conf.paths.distPublicCross);
55-
});
53+
gulp.task(
54+
'build-frontend:cross',
55+
['fonts:cross', 'icons:cross', 'assets:cross', 'index:prod', 'clean-dist'],
56+
function() { return buildFrontend(conf.paths.distPublicCross); });
5657

5758
/**
5859
* Copies assets to the dist directory for current architecture.
@@ -65,6 +66,28 @@ gulp.task('assets', ['clean-dist'], function() { return assets([conf.paths.distP
6566
gulp.task(
6667
'assets:cross', ['clean-dist'], function() { return assets(conf.paths.distPublicCross); });
6768

69+
/**
70+
* Copies icons to the dist directory for current architecture.
71+
*/
72+
gulp.task('icons', ['clean-dist'], function() { return icons(conf.paths.iconsDistPublic); });
73+
74+
/**
75+
* Copies icons to the dist directory for all architectures.
76+
*/
77+
gulp.task(
78+
'icons:cross', ['clean-dist'], function() { return icons(conf.paths.iconsDistPublicCross); });
79+
80+
/**
81+
* Copies fonts to the dist directory for current architecture.
82+
*/
83+
gulp.task('fonts', ['clean-dist'], function() { return fonts(conf.paths.fontsDistPublic); });
84+
85+
/**
86+
* Copies fonts to the dist directory for all architectures.
87+
*/
88+
gulp.task(
89+
'fonts:cross', ['clean-dist'], function() { return fonts(conf.paths.fontsDistPublicCross); });
90+
6891
/**
6992
* Cleans all build artifacts.
7093
*/
@@ -131,3 +154,27 @@ function assets(outputDirs) {
131154
return gulp.src(path.join(conf.paths.assets, '/**/*'), {base: conf.paths.app})
132155
.pipe(multiDest(outputDirs));
133156
}
157+
158+
/**
159+
* @param {string|!Array<string>} outputDirs
160+
* @return {stream}
161+
*/
162+
function icons(outputDirs) {
163+
let iconAssetsFilter = gulpFilter(['*.woff2', '*.woff', '*.eot', '*.ttf']);
164+
165+
return gulp.src(path.join(conf.paths.materialIcons, '*'), {base: conf.paths.materialIcons})
166+
.pipe(iconAssetsFilter)
167+
.pipe(multiDest(outputDirs));
168+
}
169+
170+
/**
171+
* @param {string|!Array<string>} outputDirs
172+
* @return {stream}
173+
*/
174+
function fonts(outputDirs) {
175+
let fontFilter = gulpFilter(['*.woff2']);
176+
177+
return gulp.src(path.join(conf.paths.robotoFonts, '*'), {base: conf.paths.robotoFonts})
178+
.pipe(fontFilter)
179+
.pipe(multiDest(outputDirs));
180+
}

build/conf.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,25 @@ export default {
169169
distPublicCross: arch.list.map((arch) => path.join(basePath, 'dist', arch, 'public')),
170170
distRoot: path.join(basePath, 'dist'),
171171
externs: path.join(basePath, 'src/app/externs'),
172+
fontsDistPublic: path.join(basePath, 'dist', arch.default, 'public/fonts'),
173+
fontsDistPublicCross:
174+
arch.list.map((arch) => path.join(basePath, 'dist', arch, 'public/fonts')),
172175
frontendSrc: path.join(basePath, 'src/app/frontend'),
173176
frontendTest: path.join(basePath, 'src/test/frontend'),
174177
goTools: path.join(basePath, '.tools/go'),
175178
goWorkspace: path.join(basePath, '.go_workspace'),
176179
hyperkube: path.join(basePath, 'build/hyperkube.sh'),
180+
iconsDistPublic: path.join(basePath, 'dist', arch.default, 'public/static'),
181+
iconsDistPublicCross:
182+
arch.list.map((arch) => path.join(basePath, 'dist', arch, 'public/static')),
177183
integrationTest: path.join(basePath, 'src/test/integration'),
178184
karmaConf: path.join(basePath, 'build/karma.conf.js'),
185+
materialIcons: path.join(basePath, 'bower_components/material-design-icons/iconfont'),
179186
nodeModules: path.join(basePath, 'node_modules'),
180187
partials: path.join(basePath, '.tmp/partials'),
181188
prodTmp: path.join(basePath, '.tmp/prod'),
182189
protractorConf: path.join(basePath, 'build/protractor.conf.js'),
190+
robotoFonts: path.join(basePath, 'bower_components/roboto-fontface/fonts'),
183191
serve: path.join(basePath, '.tmp/serve'),
184192
src: path.join(basePath, 'src'),
185193
tmp: path.join(basePath, '.tmp'),

src/app/frontend/index.scss

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

0 commit comments

Comments
 (0)