Skip to content

Commit

Permalink
Workaround to run on server
Browse files Browse the repository at this point in the history
  • Loading branch information
gevalo1 committed Nov 13, 2016
1 parent 30bf1d9 commit ff57949
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 107 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/nbproject/
/node_modules/
/build/*
!/build/jquery-3.1.1.min.js
/build/
11 changes: 2 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ server.listen(8085, () => {
console.log('App listening at http://localhost:8085');
});


// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
Expand All @@ -40,14 +39,8 @@ app.use(bodyParser.urlencoded({extended: false}));
app.use(cookieParser());
//app.use(express.static(path.join(__dirname, 'public')));

//app.use(express.static('./build/'));
//app.use('/*', express.static('./build/index.html')); //Always keep as last route
//app.use('/', express.static(__dirname + '/build'));
/*app.use('/*', function (req, res) {
console.log("AllRouter");
res.sendFile(__dirname + '/build/index.html');
});
*/
//Production
app.use(express.static('./build/'));

io.on('connection', (socket) => {
socket.emit('test', 'Connectedddd');
Expand Down
5 changes: 3 additions & 2 deletions client/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import './home';
import './services'
import './auth';
import './canvas';
import './normalize.css';
import './style.css';
import 'angular-material';
//development
//import './normalize.css';
//import './style.css';

// Create and bootstrap application
const requires = [
Expand Down
1 change: 0 additions & 1 deletion client/app/config/app.run.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ function AppRun(AppConstants, $rootScope) {

// change page title based on state
$rootScope.$on('$stateChangeSuccess', (event, toState) => {
console.log(toState);
$rootScope.setPageTitle(toState.title);
});

Expand Down
8 changes: 4 additions & 4 deletions client/app/config/app.templates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
<meta charset="utf-8">
<title ng-bind="pageTitle"></title>
<link type="text/css" rel="stylesheet" href="https://material.angularjs.org/latest/angular-material.min.css">
<link type="text/css" rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<!-- inject:css -->
<!-- endinject -->
</head>
<body>
<div id="wrapper">
Expand All @@ -14,5 +16,7 @@
</div>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src='/socket.io/socket.io.js' type='text/javascript'></script>
<!-- inject:js -->
<!-- endinject -->
</body>
</html>
83 changes: 83 additions & 0 deletions gulpfileserver.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
'use strict';
import gulp from 'gulp';
import del from 'del';
import source from 'vinyl-source-stream';
import browserify from 'browserify';
import babelify from 'babelify';
import ngAnnotate from 'browserify-ngannotate';
import templateCache from 'gulp-angular-templatecache';
import rename from 'gulp-rename';
import notify from 'gulp-notify';
import ejs from 'gulp-ejs';
import inject from 'gulp-inject';
import concat from 'gulp-concat';
import minifyCSS from 'gulp-minify-css';

// Where our files are located
var jsFiles = "client/app/**/*.js";
var viewFiles = "client/app/**/*.html";

var interceptErrors = (error) => {
var args = Array.prototype.slice.call(arguments);

// Send error to notification center with gulp-notify
notify.onError({
title: 'Compile Error',
message: '<%= error.message %>'
}).apply(this, args);

// Keep gulp from hanging on this task
this.emit('end');
};

gulp.task('default', ['build'], () => {
console.log("Completed build.");
});

gulp.task('build', ['browserify', 'css'], () => {
gulp.start('html');
//gulp.start() will have to be replaced by gulp.series() when gulp 4.0 is released.
});

gulp.task('browserify', ['views'], () => {
return browserify(['./client/app/app.js'])
.transform(babelify, {presets: ["es2015"]})
.transform(ngAnnotate)
.bundle()
.on('error', interceptErrors)
.pipe(source('main.js'))
.pipe(gulp.dest('./build/'));
});

gulp.task('css', () => {
gulp.src('./client/app/*.css')
.pipe(minifyCSS())
.pipe(concat('style.css'))
.on('error', interceptErrors)
.pipe(gulp.dest('./build'));
});

gulp.task('html', () => {
const sources = gulp.src(['./build/*.js', './build/*.css'], {read: false});

return gulp.src("./client/index.html")
.pipe(inject(sources, {relative: true, ignorePath: '../build/'}))
.on('error', interceptErrors)
.pipe(gulp.dest('./build/'));
});

gulp.task('views', () => {
return gulp.src(viewFiles)
.pipe(templateCache({
standalone: true
}))
.on('error', interceptErrors)
.pipe(rename("app.templates.js"))
.pipe(gulp.dest('./client/app/config/'));
});

gulp.task('clean', () => {
del(['./build/**', '!./build']).then(paths => {
console.log('Deleted files and folders:\n', paths.join('\n'));
});
});
141 changes: 53 additions & 88 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,101 +1,66 @@
{
"name": "drawing-application",
"version": "0.0.1",
"description": "Webapp using Angular 1.5.x + ES6 + Webpack",
"main": "index.js",
"dependencies": {
"angular": "^1.5.8",
"angular-animate": "^1.5.8",
"angular-aria": "^1.5.8",
"angular-chart.js": "^1.0.3",
"angular-loading-bar": "^0.9.0",
"angular-material": "^1.1.1",
"angular-material-icons": "^0.7.1",
"angular-messages": "^1.5.8",
"angular-sanitize": "^1.5.8",
"angular-ui-router": "^1.0.0-beta.1",
"angularfire": "^2.0.2",
"body-parser": "^1.15.2",
"cookie-parser": "^1.4.3",
"cors": "^2.8.1",
"express": "^4.14.0",
"express-jwt": "^5.1.0",
"jquery": "^3.1.1",
"jsonwebtoken": "^7.1.9",
"mongoose": "^4.6.3",
"morgan": "^1.7.0",
"normalize.css": "^3.0.3",
"passport": "^0.3.2",
"passport-local": "^1.0.0",
"request": "^2.75.0",
"serve-favicon": "^2.3.0"
"name": "webapps3",
"version": "1.0.0",
"description": "Project WebApps 3",
"main": "app.js",
"scripts": {
"dev": "nodemon --exec babel-node app.js",
"prestart": "babel ./app.js --out-dir ./build",
"start": "node ./build/app.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/gevalo1/WebApps3.git"
},
"author": "Thomas Buys",
"license": "ISC",
"bugs": {
"url": "https://github.com/gevalo1/WebApps3/issues"
},
"homepage": "https://github.com/gevalo1/WebApps3#readme",
"devDependencies": {
"angular-mocks": "^1.5.8",
"babel-core": "^6.17.0",
"babel-jest": "^16.0.0",
"babel-loader": "^6.2.5",
"babel-cli": "^6.18.0",
"babel-core": "^6.18.2",
"babel-loader": "^6.2.7",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-polyfill": "^6.16.0",
"babel-preset-es2015": "^6.16.0",
"babel-preset-stage-0": "^6.15.0",
"babel-register": "^6.13.3",
"babel-runtime": "^6.11.6",
"browser-sync": "^2.17.3",
"connect-history-api-fallback": "^1.3.0",
"css-loader": "^0.25.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-stage-0": "^6.16.0",
"babelify": "^7.3.0",
"browser-sync": "^2.17.5",
"browserify": "^13.1.1",
"browserify-ngannotate": "^2.0.0",
"del": "^2.2.2",
"eslint": "^3.7.1",
"fs-walk": "0.0.1",
"gulp": "^3.9.1",
"eslint": "^3.9.0",
"eslint-config-standard": "^6.2.1",
"eslint-plugin-promise": "^3.3.0",
"eslint-plugin-standard": "^2.0.1",
"gulp-angular-templatecache": "^2.0.0",
"gulp-concat": "^2.6.0",
"gulp-ejs": "^2.2.1",
"gulp-html-replace": "^1.6.1",
"gulp-inject": "^4.1.0",
"gulp-minify-css": "^1.2.4",
"gulp-nodemon": "^2.2.1",
"gulp-notify": "^2.2.0",
"gulp-rename": "^1.2.2",
"gulp-template": "^3.0.0",
"gulp-util": "^3.0.7",
"html-webpack-plugin": "^1.7.0",
"jest": "^16.0.2",
"lodash": "^4.16.4",
"ng-annotate-loader": "0.2.0",
"node-libs-browser": "^0.5.0",
"node-sass": "^3.10.1",
"raw-loader": "^0.5.1",
"run-sequence": "^1.2.2",
"sass-loader": "^4.0.2",
"style-loader": "^0.13.1",
"supports-color": "^3.1.2",
"webpack": "^1.13.2",
"webpack-dev-middleware": "^1.8.4",
"webpack-hot-middleware": "^2.13.0",
"yargs": "^3.9.0"
"gulp-uglify": "^2.0.0",
"vinyl-source-stream": "^1.1.0"
},
"scripts": {
"test": "jest",
"test:watch": "jest --watch"
},
"keywords": [
"angular",
"webpack",
"es6"
],
"author": "Thomas Buys",
"jest": {
"testPathDirs": [
"client"
],
"setupTestFrameworkScriptFile": "./jest.init.js",
"verbose": "true",
"moduleFileExtensions": [
"js"
],
"moduleDirectories": [
"node_modules"
],
"moduleNameMapper": {
"^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"^.+\\.(css|scss)$": "<rootDir>/__mocks__/styleMock.js",
"^.+\\.(html)$": "<rootDir>/__mocks__/htmlMock.js"
}
"dependencies": {
"angular": "^1.5.8",
"angular-ui-router": "^0.3.1",
"babel-cli": "^6.18.0",
"babel-register": "6.18.0",
"babel-runtime": "^6.18.0",
"body-parser": "1.15.2",
"cookie-parser": "1.4.3",
"ejs": "2.5.2",
"express": "4.14.0",
"gulp": "^3.9.1",
"mongoose": "^4.6.6",
"morgan": "1.7.0",
"serve-favicon": "2.3.0",
"socket.io": "^1.5.1"
}
}

0 comments on commit ff57949

Please sign in to comment.