Commit 5d4148a2 authored by Nicholas J Anderson's avatar Nicholas J Anderson

Merge branch 'master' into 'docker-build'

# Conflicts:
#   schedules_web/Dockerfile
parents 0c18caaf df77d0e7
var path = require('path');
var express = require('express');
var DIST_DIR = path.join(__dirname, 'dist');
var PORT = 8080;
var app = express();
//Serving the files on the dist folder
app.use(express.static(DIST_DIR));
//Send index.html when the user access the web
app.get('*', function(req, res) {
res.sendFile(path.join(DIST_DIR, 'index.html'));
});
app.listen(PORT);
......@@ -3,9 +3,9 @@
"version": "1.0.0",
"main": "index.js",
"scripts": {
"build": "webpack --config webpack.config.js --debug --progress --mode development",
"start": "webpack-dev-server --inline",
"prod": "webpack --config webpack.config.js --debug --progress --mode production"
"build": "webpack --config webpack.prod.js --debug --progress",
"start": "webpack-dev-server --config webpack.dev.js --inline --open",
"prod": "node app.js"
},
"license": "Apache",
"private": true,
......@@ -27,6 +27,7 @@
"babel-loader": "^7.1.4",
"clean-webpack-plugin": "^0.1.19",
"css-loader": "^0.28.11",
"express": "^4.16.3",
"file-loader": "^1.1.11",
"file-saver": "^1.3.8",
"html-webpack-plugin": "^3.2.0",
......@@ -38,7 +39,8 @@
"redux": "^4.0.0",
"redux-thunk": "^2.3.0",
"style-loader": "^0.21.0",
"url-loader": "^1.0.1"
"url-loader": "^1.0.1",
"webpack-merge": "^4.1.4"
},
"babel": {
"presets": [
......
class ApiService {
private apiRoot: string;
private webcalUrl: string;
public constructor(apiRoot: string) {
public constructor(apiRoot: string, webcalUrl: string) {
this.apiRoot = apiRoot;
this.webcalUrl = webcalUrl;
}
searchCourseSections = async (crn: string): Promise<any[]> =>
fetchJson(`${this.apiRoot}/course_sections?crn=${crn}`);
subscribeToCalendar = (crns: string[]) =>
window.open(`webcal://localhost:3000/api/schedules?crns=${crns.join(',')}`, '_self');
window.open(`${this.webcalUrl}/schedules?crns=${crns.join(',')}`, '_self');
}
const fetchJson = async (url: string): Promise<any> => fetch(url).then(response => response.json());
......@@ -21,4 +23,10 @@ const postJson = (endpoint: string, data: any): Promise<Response> =>
},
});
export default new ApiService('http://localhost:3000/api');
const local = 'localhost:3000/api';
const remote = 'schedules.zacwood.me/api';
const apiUrl = process.env.NODE_ENV === 'development' ? `http://${local}` : `https://${remote}`;
const webcalUrl = process.env.NODE_ENV === 'development' ? `webcal://${local}` : `webcal://${remote}`;
export default new ApiService(apiUrl, webcalUrl);
......@@ -11,9 +11,6 @@ const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
});
module.exports = {
mode: 'development',
devtool: 'source-map',
entry: './src/index.tsx',
output: {
......@@ -77,14 +74,4 @@ module.exports = {
},
plugins: [new webpack.HotModuleReplacementPlugin(), new CleanWebpackPlugin(['dist']), HtmlWebpackPluginConfig],
devServer: {
contentBase: path.resolve(__dirname, 'dist'),
compress: true,
host: '0.0.0.0',
port: 8080,
hot: true,
publicPath: '/',
historyApiFallback: true,
},
};
const path = require('path');
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: 'development',
devtool: 'source-map',
devServer: {
contentBase: path.resolve(__dirname, 'dist'),
compress: true,
host: '0.0.0.0',
port: 8080,
hot: true,
publicPath: '/',
historyApiFallback: true,
},
});
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: 'production',
});
......@@ -2946,7 +2946,7 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2:
dependencies:
homedir-polyfill "^1.0.1"
express@^4.16.2:
express@^4.16.2, express@^4.16.3:
version "4.16.3"
resolved "https://registry.yarnpkg.com/express/-/express-4.16.3.tgz#6af8a502350db3246ecc4becf6b5a34d22f7ed53"
dependencies:
......@@ -8570,6 +8570,12 @@ webpack-log@^1.0.1, webpack-log@^1.1.2, webpack-log@^1.2.0:
loglevelnext "^1.0.1"
uuid "^3.1.0"
webpack-merge@^4.1.4:
version "4.1.4"
resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.1.4.tgz#0fde38eabf2d5fd85251c24a5a8c48f8a3f4eb7b"
dependencies:
lodash "^4.17.5"
webpack-sources@^1.0.1, webpack-sources@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.1.0.tgz#a101ebae59d6507354d71d8013950a3a8b7a5a54"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment