This repository has been archived by the owner on Oct 1, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,260 additions
and
751 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
if (process.env.NODE_ENV === 'production') { | ||
process.exit(1); | ||
} | ||
|
||
process.env.NODE_ENV = 'development'; | ||
|
||
// Error.stackTraceLimit = Infinity; | ||
require('trace'); | ||
require('clarify'); | ||
|
||
const bb = require('bluebird'); | ||
require('babel-runtime/core-js/promise').default = bb; | ||
global.Promise = bb; | ||
|
||
require('./utils/hook'); | ||
const attachChangeCallback = require('./utils/watch')(); | ||
|
||
require('../server')(attachChangeCallback), | ||
require('../tasks')(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,5 @@ | ||
if (process.env.NODE_ENV === 'development') { | ||
// Error.stackTraceLimit = Infinity; | ||
require('trace'); | ||
require('clarify'); | ||
} | ||
|
||
const bb = require('bluebird'); | ||
|
||
require('babel-runtime/core-js/promise').default = bb; | ||
global.Promise = bb; | ||
|
||
require("babel-register")({ | ||
ignore: /\/(public|node_modules)\// | ||
}); | ||
|
||
const { server } = require('universal-webpack'); | ||
|
||
const settings = require('../server-uwsettings'); | ||
const configuration = require('../webpack.config.server.babel').default; | ||
|
||
server(configuration, settings); | ||
require('../public/server/server')(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,5 @@ | ||
if (process.env.NODE_ENV === 'development') { | ||
Error.stackTraceLimit = Infinity; | ||
require('trace'); | ||
require('clarify'); | ||
} | ||
|
||
const bb = require('bluebird'); | ||
|
||
require('babel-runtime/core-js/promise').default = bb; | ||
global.Promise = bb; | ||
|
||
require("babel-register")({ | ||
ignore: /\/(public|node_modules)\// | ||
}); | ||
|
||
const { server } = require('universal-webpack'); | ||
|
||
const settings = require('../tasks-uwsettings'); | ||
const configuration = require('../webpack.config.server.babel').default; | ||
|
||
server(configuration, settings); | ||
require('../public/server/tasks')(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const fs = require('fs'); | ||
const addHook = require('asset-require-hook/lib/hook'); | ||
const assetRequireHook = require('asset-require-hook'); | ||
const babelRegisterHook = require("babel-register"); | ||
|
||
function rawLoader(resourcePath) { | ||
const content = fs.readFileSync(resourcePath, 'utf-8'); | ||
return content; | ||
} | ||
|
||
// attachHook(rawLoader, '.ejs'); | ||
addHook('.ejs', rawLoader); | ||
|
||
assetRequireHook({ | ||
extensions: ['.png', 'jpg', '.gif', '.svg'], | ||
name: 'assets/images/[name]-[hash].[ext]', | ||
publicPath: '/' | ||
}); | ||
|
||
assetRequireHook({ | ||
extensions: ['.ico'], | ||
name: '[name]-[hash].[ext]', | ||
publicPath: '/' | ||
}); | ||
|
||
babelRegisterHook({ | ||
ignore: /\/(public|node_modules)\//, | ||
plugins: [ | ||
'react-hot-loader/babel' | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const path = require('path'); | ||
|
||
const watcher = require('chokidar') | ||
.watch([ | ||
path.join(__dirname, '../../src/api'), | ||
path.join(__dirname, '../../src/utils') | ||
]); | ||
|
||
module.exports = function () { | ||
const callbacks = []; | ||
|
||
watcher.on('ready', () => { | ||
watcher.on('all', () => { | ||
// eslint-disable-next-line no-console | ||
console.log('Clearing server module cache from server'); | ||
Object.keys(require.cache).forEach(id => { | ||
if (/[/\\]src[/\\](api|utils)/.test(id)) { | ||
delete require.cache[id]; | ||
} | ||
}); | ||
|
||
callbacks.forEach(c => c()); | ||
}); | ||
}); | ||
|
||
return callbacks.push.bind(callbacks); | ||
}; | ||
|
||
/* Optional: "hot-reloading" of client related modules on the server | ||
const compiler = require('webpack')(require('../../res/webpack/client.js')); | ||
compiler.plugin('done', () => { | ||
// Need to separate client and server code to prevent unnecessary reloads | ||
}); | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
This file is a part of libertysoil.org website | ||
Copyright (C) 2017 Loki Education (Social Enterprise) | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
const path = require('path'); | ||
const merge = require('lodash/merge'); | ||
const webpack = require('webpack'); | ||
|
||
const | ||
NODE_ENV = process.env.NODE_ENV, | ||
__DEV__ = NODE_ENV !== 'production', | ||
context = path.join(__dirname, '../../'); | ||
|
||
// console.log(NODE_ENV); | ||
|
||
const baseConfiguration = { | ||
context, | ||
module: { | ||
noParse: (path) => { | ||
if (/react.*\.production\.min\.js$/.test(path)) { | ||
return false; | ||
} | ||
return /\.min\.js$/.test(path); | ||
} | ||
}, | ||
output: { | ||
filename: '[name].js', | ||
publicPath: '/' | ||
}, | ||
performance: { | ||
hints: false | ||
}, | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
'process.env.NODE_ENV': JSON.stringify(NODE_ENV), | ||
'process.env.FACEBOOK_AUTH_ENABLED': !!process.env.FACEBOOK_CLIENT_ID, | ||
'process.env.GOOGLE_AUTH_ENABLED': !!process.env.GOOGLE_CLIENT_ID, | ||
'process.env.TWITTER_AUTH_ENABLED': !!process.env.TWITTER_CONSUMER_KEY, | ||
'process.env.GITHUB_AUTH_ENABLED': !!process.env.GITHUB_CLIENT_ID | ||
}), | ||
new webpack.NoEmitOnErrorsPlugin(), | ||
new webpack.LoaderOptionsPlugin({ | ||
debug: __DEV__, | ||
minimize: !__DEV__, | ||
options: { | ||
context | ||
} | ||
}) | ||
], | ||
stats: { | ||
assets: false, | ||
cached: false, | ||
children: false, | ||
chunks: true, | ||
chunkOrigins: false, | ||
modules: false, | ||
reasons: false, | ||
source: false, | ||
timings: true | ||
} | ||
}; | ||
|
||
if (__DEV__) { | ||
merge(baseConfiguration, { | ||
cache: true, | ||
performance: { | ||
hints: 'warning' | ||
}, | ||
resolve: { | ||
alias: { | ||
'prop-types$': path.join(context, './src/external/prop-types.js') | ||
} | ||
} | ||
}); | ||
} | ||
|
||
module.exports = baseConfiguration; |
Oops, something went wrong.