Skip to content

Commit 2ff359d

Browse files
committed
refactor(client): create constants module ourselves
remove gulp-ng-constant
1 parent c4b4df8 commit 2ff359d

File tree

5 files changed

+14
-32
lines changed

5 files changed

+14
-32
lines changed

templates/app/_package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
"gulp-clean-css": "^2.0.6",
9898
"gulp-mocha": "^2.1.3",
9999
"gulp-ng-annotate": "^2.0.0",
100-
"gulp-ng-constant": "^1.1.0",
101100
"gulp-node-inspector": "^0.1.0",
102101
"gulp-plumber": "^1.0.1",
103102
"gulp-protractor": "^2.1.0",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict';
2+
import angular from 'angular';
3+
4+
export default angular.module('<%= scriptAppName %>.constants', [])
5+
.constant('appConfig', require('../../server/config/environment/shared'))
6+
.name;

templates/app/client/app/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import admin from './admin';<% } %>
2626
import navbar from '../components/navbar/navbar.component';
2727
import footer from '../components/footer/footer.component';
2828
import main from './main/main.component';
29-
import './app.constant';
29+
import constants from './app.constants';
3030
import util from '../components/util/util.module';
3131
<%_ if(filters.socketio) { _%>
3232
import socket from '../components/socket/socket.service';<% } %>
@@ -56,7 +56,7 @@ angular.module('<%= scriptAppName %>', [
5656
navbar,
5757
footer,
5858
main,
59-
'<%= scriptAppName %>.constants',
59+
constants,
6060
<%_ if(filters.socketio) { _%>
6161
socket,<% } %>
6262
util

templates/app/client/components/auth(auth)/auth.module.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
import angular from 'angular';
3-
// import constants from '../../app/app.constant';
3+
import constants from '../../app/app.constants';
44
import util from '../util/util.module';
55
import ngCookies from 'angular-cookies';
66
import {authInterceptor} from './interceptor.service';
@@ -18,7 +18,7 @@ function addInterceptor($httpProvider) {
1818
}
1919

2020
export default angular.module('<%= scriptAppName %>.auth', [
21-
'<%= scriptAppName %>.constants',
21+
constants,
2222
util,
2323
ngCookies<% if(filters.ngroute) { %>,
2424
ngRoute<% } if(filters.uirouter) { %>,

templates/app/gulpfile.babel.js

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,7 @@ gulp.task('styles', () => {
268268
<%_ } _%>
269269
.pipe(styles())
270270
.pipe(gulp.dest('.tmp/app'));
271-
});<% if(filters.ts) { %>
272-
273-
gulp.task('copy:constant', ['constant'], () => {
274-
return gulp.src(`${clientPath}/app/app.constant.js`, { dot: true })
275-
.pipe(gulp.dest('.tmp/app'));
276-
});<% } %>
271+
});
277272

278273
gulp.task('transpile:server', () => {
279274
return gulp.src(_.union(paths.server.scripts, paths.server.json))
@@ -286,8 +281,7 @@ gulp.task('lint:scripts', cb => runSequence(['lint:scripts:client', 'lint:script
286281
gulp.task('lint:scripts:client', () => {
287282
return gulp.src(_.union(
288283
paths.client.scripts,
289-
_.map(paths.client.test, blob => '!' + blob),
290-
[`!${clientPath}/app/app.constant.<%= scriptExt %>`]
284+
_.map(paths.client.test, blob => '!' + blob)
291285
))
292286
.pipe(lintClientScripts());
293287
});
@@ -370,7 +364,6 @@ gulp.task('serve', cb => {
370364
[
371365
'clean:tmp',
372366
'lint:scripts',
373-
'constant',
374367
'inject',
375368
'copy:fonts:dev',
376369
'env:all'<% if(filters.ts) { %>,
@@ -388,7 +381,6 @@ gulp.task('serve:debug', cb => {
388381
[
389382
'clean:tmp',
390383
'lint:scripts',
391-
'constant',
392384
'inject',
393385
'copy:fonts:dev',
394386
'env:all'<% if(filters.ts) { %>,
@@ -471,7 +463,7 @@ gulp.task('coverage:integration', () => {
471463
// Downloads the selenium webdriver
472464
gulp.task('webdriver_update', webdriver_update);
473465

474-
gulp.task('test:e2e', ['webpack:e2e', 'constant', 'env:all', 'env:test', 'start:server', 'webdriver_update'], cb => {
466+
gulp.task('test:e2e', ['webpack:e2e', 'env:all', 'env:test', 'start:server', 'webdriver_update'], cb => {
475467
gulp.src(paths.client.e2e)
476468
.pipe(protractor({
477469
configFile: 'protractor.conf.js',
@@ -480,7 +472,7 @@ gulp.task('test:e2e', ['webpack:e2e', 'constant', 'env:all', 'env:test', 'start:
480472
.on('end', () => { process.exit() });
481473
});
482474

483-
gulp.task('test:client', ['constant'], done => {
475+
gulp.task('test:client', done => {
484476
new KarmaServer({
485477
configFile: `${__dirname}/${paths.karma}`,
486478
singleRun: true
@@ -519,21 +511,6 @@ gulp.task('build', cb => {
519511

520512
gulp.task('clean:dist', () => del([`${paths.dist}/!(.git*|.openshift|Procfile)**`], {dot: true}));
521513

522-
gulp.task('constant', function() {
523-
let sharedConfig = require(`./${serverPath}/config/environment/shared`);
524-
return plugins.ngConstant({
525-
name: '<%= scriptAppName %>.constants',
526-
deps: [],
527-
wrap: true,
528-
stream: true,
529-
constants: { appConfig: sharedConfig }
530-
})
531-
.pipe(plugins.rename({
532-
basename: 'app.constant'
533-
}))
534-
.pipe(gulp.dest(`${clientPath}/app/`))
535-
});
536-
537514
gulp.task('build:images', () => {
538515
return gulp.src(paths.client.images)
539516
.pipe(plugins.imagemin({

0 commit comments

Comments
 (0)