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
|
||||
ENV= #Default production
|
||||
#App Port
|
||||
PORT= #Default 80
|
||||
#PUBLIC URL
|
||||
PUBLIC_URL= #Default 'auto'
|
||||
#Prefix URL
|
||||
PREFIX_URL= #Default ''
|
||||
#ONLY EXACT PATH
|
||||
ONLY_EXACT_PATH= #Default false
|
||||
PORT= #Default 80
|
@ -1,12 +1,14 @@
|
||||
{
|
||||
"name": "@aleleba/create-react-go-ssr",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"description": "Starter Kit of server side render of react",
|
||||
"bin": "./bin/cli.js",
|
||||
"main": "src/server/index",
|
||||
"scripts": {
|
||||
"start": "cd build/server && ./react-server",
|
||||
"start-frontend:dev": "webpack watch --config webpack.config.ts",
|
||||
"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:fix": "eslint ./ --ext .js --ext .ts --ext .jsx --ext .tsx --fix",
|
||||
"test": "jest",
|
||||
@ -23,6 +25,8 @@
|
||||
"keywords": [
|
||||
"create react app",
|
||||
"react",
|
||||
"go",
|
||||
"golang",
|
||||
"ssr",
|
||||
"typescript",
|
||||
"redux"
|
||||
|
@ -1,15 +1,18 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import PrincipalRoutes from './PrincipalRoutes';
|
||||
import { config } from '../../../config';
|
||||
|
||||
const App = () => {
|
||||
useEffect(() => {
|
||||
const ws = new WebSocket('wss://nmr4jbx8-3000.use.devtunnels.ms/ws');
|
||||
ws.onmessage = (event) => {
|
||||
if (event.data === 'reload') {
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
if(config.ENV === 'development') {
|
||||
useEffect(() => {
|
||||
const ws = new WebSocket('wss://nmr4jbx8-3000.use.devtunnels.ms/ws');
|
||||
ws.onmessage = (event) => {
|
||||
if (event.data === 'reload') {
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
}
|
||||
|
||||
return <PrincipalRoutes />;
|
||||
};
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
func LoadEnv() {
|
||||
err := godotenv.Load("../../.env")
|
||||
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
|
||||
port := os.Getenv("PORT")
|
||||
|
||||
if(port == "") {
|
||||
port = "80"
|
||||
}
|
||||
|
||||
paths := utils.GetRoutes()
|
||||
|
||||
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_CONVERSION = resolvePath(__dirname + '/src/server/web/conversion');
|
||||
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 alias = resolveTsAliases(path.resolve('tsconfig.json'));
|
||||
|
||||
@ -131,10 +131,10 @@ const configReact = {
|
||||
new CopyPlugin({
|
||||
patterns: copyPatterns
|
||||
}),
|
||||
/*new InjectManifest({
|
||||
new InjectManifest({
|
||||
swSrc: './service-worker.ts',
|
||||
swDest: 'service-worker.js',
|
||||
}),*/
|
||||
}),
|
||||
],
|
||||
optimization: {
|
||||
minimize: true,
|
||||
|
Loading…
Reference in New Issue
Block a user