Configure the build and the start of the app in prod. Updating to version 0.1.1
This commit is contained in:
parent
ec020257e0
commit
3ea012cf93
@ -1,10 +1,4 @@
|
|||||||
#Environment
|
#Environment
|
||||||
ENV= #Default production
|
ENV= #Default production
|
||||||
#App Port
|
#App Port
|
||||||
PORT= #Default 80
|
PORT= #Default 80
|
||||||
#PUBLIC URL
|
|
||||||
PUBLIC_URL= #Default 'auto'
|
|
||||||
#Prefix URL
|
|
||||||
PREFIX_URL= #Default ''
|
|
||||||
#ONLY EXACT PATH
|
|
||||||
ONLY_EXACT_PATH= #Default false
|
|
@ -1,12 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "@aleleba/create-react-go-ssr",
|
"name": "@aleleba/create-react-go-ssr",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"description": "Starter Kit of server side render of react",
|
"description": "Starter Kit of server side render of react",
|
||||||
"bin": "./bin/cli.js",
|
"bin": "./bin/cli.js",
|
||||||
"main": "src/server/index",
|
"main": "src/server/index",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"start": "cd build/server && ./react-server",
|
||||||
"start-frontend:dev": "webpack watch --config webpack.config.ts",
|
"start-frontend:dev": "webpack watch --config webpack.config.ts",
|
||||||
"start-server:dev": "cd src/server && go run main.go",
|
"start-server:dev": "cd src/server && go run main.go",
|
||||||
|
"build": "webpack --config webpack.config.ts && cd src/server && go build && mkdir ../../build && cp -r ./ ../../build/server && cp -r ../routes ../../build/routes && rm -rf ./react-server",
|
||||||
"lint": "eslint ./ --ext .js --ext .ts --ext .jsx --ext .tsx",
|
"lint": "eslint ./ --ext .js --ext .ts --ext .jsx --ext .tsx",
|
||||||
"lint:fix": "eslint ./ --ext .js --ext .ts --ext .jsx --ext .tsx --fix",
|
"lint:fix": "eslint ./ --ext .js --ext .ts --ext .jsx --ext .tsx --fix",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
@ -23,6 +25,8 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"create react app",
|
"create react app",
|
||||||
"react",
|
"react",
|
||||||
|
"go",
|
||||||
|
"golang",
|
||||||
"ssr",
|
"ssr",
|
||||||
"typescript",
|
"typescript",
|
||||||
"redux"
|
"redux"
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import PrincipalRoutes from './PrincipalRoutes';
|
import PrincipalRoutes from './PrincipalRoutes';
|
||||||
|
import { config } from '../../../config';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
useEffect(() => {
|
if(config.ENV === 'development') {
|
||||||
const ws = new WebSocket('wss://nmr4jbx8-3000.use.devtunnels.ms/ws');
|
useEffect(() => {
|
||||||
ws.onmessage = (event) => {
|
const ws = new WebSocket('wss://nmr4jbx8-3000.use.devtunnels.ms/ws');
|
||||||
if (event.data === 'reload') {
|
ws.onmessage = (event) => {
|
||||||
window.location.reload();
|
if (event.data === 'reload') {
|
||||||
}
|
window.location.reload();
|
||||||
};
|
}
|
||||||
}, []);
|
};
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
|
|
||||||
return <PrincipalRoutes />;
|
return <PrincipalRoutes />;
|
||||||
};
|
};
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
func LoadEnv() {
|
func LoadEnv() {
|
||||||
err := godotenv.Load("../../.env")
|
err := godotenv.Load("../../.env")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Error loading .env file")
|
// log.Fatal("Error loading .env file")
|
||||||
|
log.Println("Is no .env file")
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,6 +21,10 @@ func main() {
|
|||||||
//Getting the port from the environment
|
//Getting the port from the environment
|
||||||
port := os.Getenv("PORT")
|
port := os.Getenv("PORT")
|
||||||
|
|
||||||
|
if(port == "") {
|
||||||
|
port = "80"
|
||||||
|
}
|
||||||
|
|
||||||
paths := utils.GetRoutes()
|
paths := utils.GetRoutes()
|
||||||
|
|
||||||
e := echo.New()
|
e := echo.New()
|
||||||
|
@ -18,7 +18,7 @@ const resolvePath = (...args) => path.resolve(ROOT_DIR, ...args);
|
|||||||
const BUILD_DIR = resolvePath(__dirname + '/src/server/web/dist');
|
const BUILD_DIR = resolvePath(__dirname + '/src/server/web/dist');
|
||||||
const BUILD_DIR_CONVERSION = resolvePath(__dirname + '/src/server/web/conversion');
|
const BUILD_DIR_CONVERSION = resolvePath(__dirname + '/src/server/web/conversion');
|
||||||
const BUILD_DIR_GET_STATE = resolvePath(__dirname + '/src/server/web/getstate');
|
const BUILD_DIR_GET_STATE = resolvePath(__dirname + '/src/server/web/getstate');
|
||||||
//const { InjectManifest } = require('workbox-webpack-plugin');
|
const { InjectManifest } = require('workbox-webpack-plugin');
|
||||||
//const nodeExternals = require('webpack-node-externals');
|
//const nodeExternals = require('webpack-node-externals');
|
||||||
const alias = resolveTsAliases(path.resolve('tsconfig.json'));
|
const alias = resolveTsAliases(path.resolve('tsconfig.json'));
|
||||||
|
|
||||||
@ -131,10 +131,10 @@ const configReact = {
|
|||||||
new CopyPlugin({
|
new CopyPlugin({
|
||||||
patterns: copyPatterns
|
patterns: copyPatterns
|
||||||
}),
|
}),
|
||||||
/*new InjectManifest({
|
new InjectManifest({
|
||||||
swSrc: './service-worker.ts',
|
swSrc: './service-worker.ts',
|
||||||
swDest: 'service-worker.js',
|
swDest: 'service-worker.js',
|
||||||
}),*/
|
}),
|
||||||
],
|
],
|
||||||
optimization: {
|
optimization: {
|
||||||
minimize: true,
|
minimize: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user