fixed server bundle
This commit is contained in:
parent
81edb47e41
commit
701cc64062
2 changed files with 61 additions and 44 deletions
|
@ -1,7 +1,7 @@
|
||||||
const fs = require('fs');
|
// const fs = require('fs');
|
||||||
const path = require('path');
|
// const path = require('path');
|
||||||
const Sequelize = require('sequelize');
|
const Sequelize = require('sequelize');
|
||||||
const basename = path.basename(module.filename);
|
// const basename = path.basename(module.filename);
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const config = require('../config/speechConfig.js');
|
const config = require('../config/speechConfig.js');
|
||||||
const { database, username, password } = config.sql;
|
const { database, username, password } = config.sql;
|
||||||
|
@ -30,16 +30,30 @@ sequelize
|
||||||
logger.error('Sequelize was unable to connect to the database:', err);
|
logger.error('Sequelize was unable to connect to the database:', err);
|
||||||
});
|
});
|
||||||
|
|
||||||
// add each model to the db object
|
// // add each model to the db object
|
||||||
fs
|
// fs
|
||||||
.readdirSync(__dirname)
|
// .readdirSync(__dirname)
|
||||||
.filter(file => {
|
// .filter(file => {
|
||||||
return (file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js');
|
// return (file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js');
|
||||||
})
|
// })
|
||||||
.forEach(file => {
|
// .forEach(file => {
|
||||||
const model = sequelize['import'](path.join(__dirname, file));
|
// const model = sequelize['import'](path.join(__dirname, file));
|
||||||
db[model.name] = model;
|
// db[model.name] = model;
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
// manually add each model to the db
|
||||||
|
const Certificate = require('./certificate.js');
|
||||||
|
const Channel = require('./channel.js');
|
||||||
|
const Claim = require('./claim.js');
|
||||||
|
const File = require('./file.js');
|
||||||
|
const Request = require('./request.js');
|
||||||
|
const User = require('./user.js');
|
||||||
|
db['Certificate'] = sequelize.import('Certificate', Certificate);
|
||||||
|
db['Channel'] = sequelize.import('Channel', Channel);
|
||||||
|
db['Claim'] = sequelize.import('Claim', Claim);
|
||||||
|
db['File'] = sequelize.import('File', File);
|
||||||
|
db['Request'] = sequelize.import('Request', Request);
|
||||||
|
db['User'] = sequelize.import('User', User);
|
||||||
|
|
||||||
// run model.association for each model in the db object that has an association
|
// run model.association for each model in the db object that has an association
|
||||||
Object.keys(db).forEach(modelName => {
|
Object.keys(db).forEach(modelName => {
|
||||||
|
|
|
@ -5,38 +5,41 @@ const REACT_ROOT = Path.resolve(__dirname, 'react/');
|
||||||
console.log('REACT_ROOT:', REACT_ROOT);
|
console.log('REACT_ROOT:', REACT_ROOT);
|
||||||
|
|
||||||
module.exports = [
|
module.exports = [
|
||||||
// {
|
|
||||||
// target: 'web',
|
|
||||||
// entry : ['babel-polyfill', 'whatwg-fetch', './react/client.js'],
|
|
||||||
// output: {
|
|
||||||
// path : Path.join(__dirname, 'public/bundle/'),
|
|
||||||
// publicPath: 'public/bundle/',
|
|
||||||
// filename : 'bundle.js',
|
|
||||||
// },
|
|
||||||
// watch : true,
|
|
||||||
// module: {
|
|
||||||
// loaders: [
|
|
||||||
// {
|
|
||||||
// test : /.jsx?$/,
|
|
||||||
// loader : 'babel-loader',
|
|
||||||
// exclude: /node_modules/,
|
|
||||||
// query : {
|
|
||||||
// presets: ['es2015', 'react', 'stage-2'],
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// resolve: {
|
|
||||||
// modules: [
|
|
||||||
// REACT_ROOT,
|
|
||||||
// 'node_modules',
|
|
||||||
// __dirname,
|
|
||||||
// ],
|
|
||||||
// extensions: ['.js', '.jsx', '.scss'],
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
target : 'node',
|
target: 'web',
|
||||||
|
entry : ['babel-polyfill', 'whatwg-fetch', './react/client.js'],
|
||||||
|
output: {
|
||||||
|
path : Path.join(__dirname, 'public/bundle/'),
|
||||||
|
publicPath: 'public/bundle/',
|
||||||
|
filename : 'bundle.js',
|
||||||
|
},
|
||||||
|
watch : true,
|
||||||
|
module: {
|
||||||
|
loaders: [
|
||||||
|
{
|
||||||
|
test : /.jsx?$/,
|
||||||
|
loader : 'babel-loader',
|
||||||
|
exclude: /node_modules/,
|
||||||
|
query : {
|
||||||
|
presets: ['es2015', 'react', 'stage-2'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
modules: [
|
||||||
|
REACT_ROOT,
|
||||||
|
'node_modules',
|
||||||
|
__dirname,
|
||||||
|
],
|
||||||
|
extensions: ['.js', '.jsx', '.scss'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'node',
|
||||||
|
node : {
|
||||||
|
__dirname: false,
|
||||||
|
},
|
||||||
externals: [nodeExternals()],
|
externals: [nodeExternals()],
|
||||||
entry : ['./server.js'],
|
entry : ['./server.js'],
|
||||||
output : {
|
output : {
|
||||||
|
|
Loading…
Reference in a new issue