Skip to content

Commit af4b908

Browse files
committed
Merge pull request #1260 from kingcody/feature/compile-server-on-build
feat(app): compile server with babel-runtime
2 parents f0cff1b + 8b708e2 commit af4b908

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

Diff for: app/templates/Gruntfile.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -581,22 +581,33 @@ module.exports = function (grunt) {
581581
ext: '.js'
582582
}]
583583
}
584-
},<% } if(filters.babel) { %>
584+
},<% } %>
585585

586586
// Compiles ES6 to JavaScript using Babel
587587
babel: {
588588
options: {
589589
sourceMap: true
590-
},
590+
},<% if(filters.babel) { %>
591591
client: {
592592
files: [{
593593
expand: true,
594594
cwd: '<%%= yeoman.client %>',
595595
src: ['{app,components}/**/!(*.spec).js'],
596596
dest: '.tmp'
597597
}]
598+
},<% } %>
599+
server: {
600+
options: {
601+
optional: ['runtime']
602+
},
603+
files: [{
604+
expand: true,
605+
cwd: '<%%= yeoman.server %>',
606+
src: ['**/*.{js,json}'],
607+
dest: '<%%= yeoman.dist %>/<%%= yeoman.server %>'
608+
}]
598609
}
599-
},<% } if(filters.stylus) { %>
610+
},<% if(filters.stylus) { %>
600611

601612
// Compiles Stylus to CSS
602613
stylus: {
@@ -902,6 +913,7 @@ module.exports = function (grunt) {
902913
'concat',
903914
'ngAnnotate',
904915
'copy:dist',
916+
'babel:server',
905917
'cdnify',
906918
'cssmin',
907919
'uglify',

Diff for: app/templates/_package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"composable-middleware": "^0.3.0",
1515
"lodash": "^3.10.1",
1616
"lusca": "^1.3.0",
17-
"babel-core": "^5.6.4",<% if (filters.jade) { %>
17+
"babel-runtime": "^5.8.20",<% if (filters.jade) { %>
1818
"jade": "^1.11.0",<% } %><% if (filters.html) { %>
1919
"ejs": "^2.3.3",<% } %><% if (filters.mongoose) { %>
2020
"mongoose": "^4.1.2",
@@ -37,6 +37,7 @@
3737
},
3838
"devDependencies": {
3939
"autoprefixer": "^6.0.0",
40+
"babel-core": "^5.6.4",
4041
"grunt": "~0.4.5",
4142
"grunt-wiredep": "^2.0.0",
4243
"grunt-concurrent": "^2.0.1",

Diff for: app/templates/server/app.js

-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
'use strict';
66

7-
// Set default node environment to development
8-
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
9-
107
import express from 'express';<% if (filters.mongoose) { %>
118
import mongoose from 'mongoose';<% } %><% if (filters.sequelize) { %>
129
import sqldb from './sqldb';<% } %>

Diff for: app/templates/server/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
'use strict';
22

3-
// Register the Babel require hook
4-
require('babel-core/register');
3+
// Set default node environment to development
4+
var env = process.env.NODE_ENV = process.env.NODE_ENV || 'development';
5+
6+
if (env === 'production' || env === 'test') {
7+
// Register the Babel require hook
8+
require('babel-core/register');
9+
}
510

611
// Export the application
712
exports = module.exports = require('./app');

0 commit comments

Comments
 (0)