more settings

This commit is contained in:
Jori Lallo
2016-05-23 22:55:42 -07:00
parent eefd871966
commit 4ca38b8a63
6 changed files with 24 additions and 15 deletions

View File

@ -2,8 +2,6 @@ require('./init');
var app = require('./server').default; var app = require('./server').default;
var http = require('http'); var http = require('http');
console.log(process.env);
var server = http.createServer(app.callback()); var server = http.createServer(app.callback());
server.listen(process.env.PORT || '3000'); server.listen(process.env.PORT || '3000');
server.on('error', (err) => { server.on('error', (err) => {

View File

@ -28,12 +28,17 @@ if (process.env.NODE_ENV === 'production') {
console.log(path.join(__dirname, '../dist/', ctx.path.substring(8))); console.log(path.join(__dirname, '../dist/', ctx.path.substring(8)));
const stats = await sendfile(ctx, path.join(__dirname, '../dist/', ctx.path.substring(8))); const stats = await sendfile(ctx, path.join(__dirname, '../dist/', ctx.path.substring(8)));
}); });
}
router.get('*', async (ctx) => { router.get('*', async (ctx) => {
const stats = await sendfile(ctx, path.join(__dirname, '../dist/index.html')); const stats = await sendfile(ctx, path.join(__dirname, '../dist/index.html'));
if (!ctx.status) ctx.throw(httpErrors.NotFound()); if (!ctx.status) ctx.throw(httpErrors.NotFound());
}); });
} else {
router.get('*', async (ctx) => {
const stats = await sendfile(ctx, path.join(__dirname, './static/dev.html'));
if (!ctx.status) ctx.throw(httpErrors.NotFound());
});
}
koa.use(router.routes()); koa.use(router.routes());

View File

@ -1,7 +1,8 @@
// Constant values let constants;
const constants = {
constants = {
API_USER_AGENT: `Atlas`, API_USER_AGENT: `Atlas`,
API_BASE_URL: 'http://localhost:3000/api', API_BASE_URL: '/api',
}; };
export default Object.assign(keys, constants); export default constants;

View File

@ -1,5 +1,6 @@
var path = require('path');
var webpack = require('webpack'); var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
const commonWebpackConfig = require('./webpack.config'); const commonWebpackConfig = require('./webpack.config');
@ -15,5 +16,9 @@ const developmentWebpackConfig = Object.assign(commonWebpackConfig, {
developmentWebpackConfig.plugins.push(new webpack.optimize.OccurenceOrderPlugin()); developmentWebpackConfig.plugins.push(new webpack.optimize.OccurenceOrderPlugin());
developmentWebpackConfig.plugins.push(new webpack.HotModuleReplacementPlugin()); developmentWebpackConfig.plugins.push(new webpack.HotModuleReplacementPlugin());
developmentWebpackConfig.plugins.push(new webpack.NoErrorsPlugin()); developmentWebpackConfig.plugins.push(new webpack.NoErrorsPlugin());
developmentWebpackConfig.plugins.push(new ExtractTextPlugin('styles.css'));
developmentWebpackConfig.plugins.push(new HtmlWebpackPlugin({
title: 'Atlas',
}));
module.exports = developmentWebpackConfig; module.exports = developmentWebpackConfig;

View File

@ -1,7 +1,6 @@
var path = require('path'); var path = require('path');
var webpack = require('webpack'); var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin"); var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require('html-webpack-plugin');
// Load .env // Load .env
require('dotenv').config(); require('dotenv').config();
@ -38,7 +37,7 @@ module.exports = {
] ]
}, },
resolve: { resolve: {
root: path.resolve('./src'), root: path.join(__dirname, 'src'),
// you can now require('file') instead of require('file.json') // you can now require('file') instead of require('file.json')
extensions: ['', '.js', '.json'] extensions: ['', '.js', '.json']
}, },
@ -47,6 +46,5 @@ module.exports = {
new webpack.ProvidePlugin({ new webpack.ProvidePlugin({
'fetch': 'imports?this=>global!exports?global.fetch!isomorphic-fetch' 'fetch': 'imports?this=>global!exports?global.fetch!isomorphic-fetch'
}), }),
new ExtractTextPlugin('styles.[hash].css'),
] ]
}; };

View File

@ -1,6 +1,7 @@
var path = require('path'); var path = require('path');
var webpack = require('webpack'); var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin'); var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
commonWebpackConfig = require('./webpack.config'); commonWebpackConfig = require('./webpack.config');
@ -20,6 +21,7 @@ productionWebpackConfig = Object.assign(commonWebpackConfig, {
productionWebpackConfig.plugins.push(new HtmlWebpackPlugin({ productionWebpackConfig.plugins.push(new HtmlWebpackPlugin({
template: 'server/static/index.html' template: 'server/static/index.html'
})); }));
productionWebpackConfig.plugins.push(new ExtractTextPlugin('styles.[hash].css'));
productionWebpackConfig.plugins.push(new webpack.optimize.OccurenceOrderPlugin()); productionWebpackConfig.plugins.push(new webpack.optimize.OccurenceOrderPlugin());
productionWebpackConfig.plugins.push( productionWebpackConfig.plugins.push(
new webpack.optimize.UglifyJsPlugin({ new webpack.optimize.UglifyJsPlugin({