Commit 56252642 authored by Matija Obreza's avatar Matija Obreza
Browse files

Express: setup

fixed ssr express startup
parent 7ad152fd
...@@ -15,7 +15,7 @@ module.exports = { ...@@ -15,7 +15,7 @@ module.exports = {
target: 'node', target: 'node',
mode: ifThenElse(IS_PRODUCTION, 'production', 'development'), mode: ifThenElse(IS_PRODUCTION, 'production', 'development'),
entry: { entry: {
server: ['./src/index.ts'] server: ['./server/index.ts']
}, },
output: { output: {
......
...@@ -46,7 +46,7 @@ module.exports = { ...@@ -46,7 +46,7 @@ module.exports = {
devServer: { devServer: {
hot: true, hot: true,
inline: true, inline: true,
contentBase: path.join(__dirname, '../../../'), contentBase: path.join(__dirname, '../'),
compress: true, compress: true,
port: PORT, port: PORT,
host: HOST, host: HOST,
...@@ -115,7 +115,7 @@ module.exports = { ...@@ -115,7 +115,7 @@ module.exports = {
}, },
entry: { entry: {
genesys: [ 'babel-polyfill', './entrypoints/client.tsx' ], gringlobal: [ 'babel-polyfill', './entrypoints/client.tsx' ],
}, },
output: { output: {
...@@ -172,14 +172,14 @@ module.exports = { ...@@ -172,14 +172,14 @@ module.exports = {
// Inject scripts to app's real index.html // Inject scripts to app's real index.html
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
title: 'Genesys', // The title to use for the generated HTML document title: 'GRIN-Global Client', // The title to use for the generated HTML document
filename: 'index.html', // The file to write the HTML to filename: 'index.html', // The file to write the HTML to
// minify: {...}, // Pass a html-minifier options object to minify the output // minify: {...}, // Pass a html-minifier options object to minify the output
xhtml: true, xhtml: true,
excludeAssets: [/server(\..+)*\.js/], excludeAssets: [/server(\..+)*\.js/],
template: './entrypoints/index.html', template: './entrypoints/index.html',
// chunksSortMode: sortedChunks(['vendor', 'common', 'genesys']), // chunksSortMode: sortedChunks(['vendor', 'common', 'gringlobal']),
// chunks: ['vendor', 'common', 'genesys'], // chunks: ['vendor', 'common', 'gringlobal'],
favicon: 'favicon.ico', favicon: 'favicon.ico',
version: gitRevisionPlugin.version(), version: gitRevisionPlugin.version(),
commithash: gitRevisionPlugin.commithash(), commithash: gitRevisionPlugin.commithash(),
...@@ -188,14 +188,14 @@ module.exports = { ...@@ -188,14 +188,14 @@ module.exports = {
// Inject scripts for SSR // Inject scripts for SSR
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
title: 'Genesys', // The title to use for the generated HTML document title: 'GRIN-Global Client', // The title to use for the generated HTML document
filename: 'ssr-compiled.html', // The file to write the HTML to filename: 'ssr-compiled.html', // The file to write the HTML to
// minify: {...}, // Pass a html-minifier options object to minify the output // minify: {...}, // Pass a html-minifier options object to minify the output
xhtml: true, xhtml: true,
excludeAssets: [/server(\..+)*\.js/], excludeAssets: [/server(\..+)*\.js/],
template: './assets/html/ssr-template.html', template: './assets/html/ssr-template.html',
// chunksSortMode: sortedChunks(['vendor', 'common', 'genesys']), // chunksSortMode: sortedChunks(['vendor', 'common', 'gringlobal']),
// chunks: ['vendor', 'common', 'genesys'], // chunks: ['vendor', 'common', 'gringlobal'],
favicon: 'favicon.ico', favicon: 'favicon.ico',
version: gitRevisionPlugin.version(), version: gitRevisionPlugin.version(),
commithash: gitRevisionPlugin.commithash(), commithash: gitRevisionPlugin.commithash(),
...@@ -203,7 +203,7 @@ module.exports = { ...@@ -203,7 +203,7 @@ module.exports = {
}), }),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
title: 'Genesys', // The title to use for the generated HTML document title: 'GRIN-Global Client', // The title to use for the generated HTML document
filename: 'ssr-error.html', // The file to write the HTML to filename: 'ssr-error.html', // The file to write the HTML to
xhtml: true, xhtml: true,
excludeAssets: [/server(\..+)*\.ts/], excludeAssets: [/server(\..+)*\.ts/],
...@@ -215,7 +215,7 @@ module.exports = { ...@@ -215,7 +215,7 @@ module.exports = {
// Defer/Async scripts // Defer/Async scripts
new ScriptExtHtmlWebpackPlugin({ new ScriptExtHtmlWebpackPlugin({
defaultAttribute: 'async', defaultAttribute: 'async',
// async: [ 'genesys' ], // async: [ 'gringlobal' ],
}), }),
// Keep CSS separate // Keep CSS separate
......
...@@ -50,6 +50,7 @@ const SsrI18nProvider = withSSR()(I18nextProvider) as any; ...@@ -50,6 +50,7 @@ const SsrI18nProvider = withSSR()(I18nextProvider) as any;
// Configure axios for client // Configure axios for client
configureBackendApi({ apiUrl: store.getState().applicationConfig.apiUrl || process.env.API_URL || 'http://localhost:8080' }); configureBackendApi({ apiUrl: store.getState().applicationConfig.apiUrl || process.env.API_URL || 'http://localhost:8080' });
console.log('Here we are!', i18nClient);
sagaMiddleware.run(saga); sagaMiddleware.run(saga);
if (__PRELOADED_STATE__ === undefined) { if (__PRELOADED_STATE__ === undefined) {
......
...@@ -4,11 +4,12 @@ ...@@ -4,11 +4,12 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"description": "", "description": "",
"scripts": { "scripts": {
"i18nGenerate": "cross-env moduleName=express includedLocales=['../client/locales/**/*.json'] lerna run i18n:generateI18n --stream", "clean": "rimraf generated",
"build": "lerna run precompile && yarn run build:client && yarn run build:server", "i18nGenerate": "cross-env moduleName=express includedLocales=['../client/locales/**/*.json'] gg-i18n",
"build": "yarn run i18nGenerate && yarn run build:client && yarn run build:server",
"build:server": "webpack --config config/server.config.js", "build:server": "webpack --config config/server.config.js",
"build:client": "cross-env NODE_ENV=development SSR=true webpack --config config/webpack-production.config.js", "build:client": "cross-env NODE_ENV=development SSR=true webpack --config config/webpack-production.config.js",
"start:dev": "lerna run precompile && cross-env NODE_OPTIONS=--max_old_space_size=8192 webpack-dev-server --config config/webpack-development.config.js", "start:dev": "yarn run i18nGenerate && cross-env NODE_OPTIONS=--max_old_space_size=8192 webpack-dev-server --config config/webpack-development.config.js",
"start:prod": "yarn run build && cd ../../target/app/server && node server.js" "start:prod": "yarn run build && cd ../../target/app/server && node server.js"
}, },
"dependencies": { "dependencies": {
......
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