mirror of
				https://github.com/aleleba/create-react-ssr.git
				synced 2025-10-30 21:51:01 -06:00 
			
		
		
		
	PR-753737: Cambiando la carpeta src a client y moviendo todo a una carpeta dentro de client llamada src.
This commit is contained in:
		
							
								
								
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,9 +1,9 @@ | ||||
| #node_modules ignore | ||||
| src/node_modules | ||||
| client/node_modules | ||||
| server/node_modules | ||||
| #.envs | ||||
| src/.env | ||||
| client/.env | ||||
| server/.env | ||||
| #builds | ||||
| src/build | ||||
| client/build | ||||
| server/build | ||||
| @@ -2,10 +2,10 @@ | ||||
|   "name": "create-react-ssr", | ||||
|   "version": "1.0.0", | ||||
|   "description": "Starter Kit de server side render de react", | ||||
|   "main": "index.js", | ||||
|   "main": "src/server/index", | ||||
|   "scripts": { | ||||
|     "start": "ts-node server", | ||||
|     "start:dev": "nodemon --exec 'ts-node' server/index -e js,json,ts,tsx,jsx", | ||||
|     "start": "ts-node src/server", | ||||
|     "start:dev": "nodemon --exec 'ts-node' src/server/index -e js,json,ts,tsx,jsx", | ||||
|     "build": "webpack-cli --config webpack.config.js", | ||||
|     "lint": "eslint ./ --ext .js --ext .ts --ext .jsx --ext .tsx", | ||||
|     "lint:fix": "eslint ./ --ext .js --ext .ts --ext .jsx --ext .tsx --fix", | ||||
| @@ -6,11 +6,11 @@ import { BrowserRouter as Router } from 'react-router-dom'; | ||||
| import { Provider } from 'react-redux'; | ||||
| import { IInitialState } from './reducers/index.js'; | ||||
| import setStore from './setStore.js'; | ||||
| import { config } from '../config'; | ||||
| import { config } from '../../config'; | ||||
| 
 | ||||
| import './styles/global.sass'; | ||||
| import App from './components/App'; | ||||
| import serviceWorkerRegistration from '../serviceWorkerRegistration'; | ||||
| import serviceWorkerRegistration from '../../serviceWorkerRegistration'; | ||||
| 
 | ||||
| declare global { | ||||
| 	interface Window { | ||||
| @@ -2,7 +2,7 @@ | ||||
| import { createStore } from 'redux'; //, applyMiddleware
 | ||||
| // import { Provider } from 'react-redux';
 | ||||
| import { composeWithDevTools as composeWithDevToolsWeb } from 'redux-devtools-extension'; | ||||
| import { config } from '../config'; | ||||
| import { config } from '../../config'; | ||||
| import reducer from './reducers'; | ||||
| 
 | ||||
| const { env } = config; | ||||
							
								
								
									
										13
									
								
								client/src/server/getHashManifest.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								client/src/server/getHashManifest.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| import fs from 'fs'; | ||||
|  | ||||
| const getHashManifest = () => { | ||||
| 	try { | ||||
| 		const baseUrl = __dirname.replace(/\/client(.*)/,''); | ||||
| 		const fullURL = `${baseUrl}/client/build/assets/manifest-hash.json` ; | ||||
| 		return JSON.parse(fs.readFileSync(fullURL)); | ||||
| 	}catch(err){ | ||||
| 		console.error(err); | ||||
| 	} | ||||
| }; | ||||
|  | ||||
| export default getHashManifest; | ||||
| @@ -1,11 +1,11 @@ | ||||
| //Dependencies of Server
 | ||||
| import express from 'express'; | ||||
| import { config } from '../config'; | ||||
| import { config } from '../../config'; | ||||
| import webpack from 'webpack'; | ||||
| import helmet from 'helmet'; | ||||
| 
 | ||||
| //Dependencies of HotReloading
 | ||||
| import webpackConfig from '../webpack.config.dev'; | ||||
| import webpackConfig from '../../webpack.config.dev'; | ||||
| import webpackDevMiddleware from 'webpack-dev-middleware'; | ||||
| import webpackHotMiddleware from 'webpack-hot-middleware'; | ||||
| 
 | ||||
| @@ -44,12 +44,14 @@ if(env === 'development'){ | ||||
| 			heartbeat: 1000, | ||||
| 		})); | ||||
| }else{ | ||||
| 	const baseUrl = __dirname.replace(/\/client(.*)/,''); | ||||
| 	const fullURL = `${baseUrl}/client/build` ; | ||||
| 	app | ||||
| 		.use((req, res, next) => { | ||||
| 			if(!req.hashManifest) req.hashManifest = getHashManifest(); | ||||
| 			next(); | ||||
| 		}) | ||||
| 		.use(express.static(`${__dirname}/../build`)) | ||||
| 		.use(express.static(fullURL)) | ||||
| 		.use(helmet()) | ||||
| 		.use(helmet.permittedCrossDomainPolicies()) | ||||
| 		.use(helmet({ | ||||
| @@ -7,7 +7,7 @@ const ESLintPlugin = require('eslint-webpack-plugin'); | ||||
| const PUBLIC_URL = process.env.PUBLIC_URL || '/'; | ||||
| 
 | ||||
| module.exports = { | ||||
| 	entry: ['webpack-hot-middleware/client?path=/reload_wss&timeout=2000&reload=true&autoConnect=true', './frontend/index.tsx'], | ||||
| 	entry: ['webpack-hot-middleware/client?path=/reload_wss&timeout=2000&reload=true&autoConnect=true', './src/frontend/index.tsx'], | ||||
| 	output: { | ||||
| 		path: path.resolve(__dirname, 'build'), | ||||
| 		filename: 'assets/app.js', | ||||
| @@ -16,8 +16,8 @@ module.exports = { | ||||
| 	resolve: { | ||||
| 		extensions: ['.js', '.jsx','.ts','.tsx', '.json'], | ||||
| 		alias: { | ||||
| 			'@components': path.resolve(__dirname, 'frontend/components/'), | ||||
| 			'@styles': path.resolve(__dirname, 'frontend/styles/'), | ||||
| 			'@components': path.resolve(__dirname, 'src/frontend/components/'), | ||||
| 			'@styles': path.resolve(__dirname, 'src/frontend/styles/'), | ||||
| 		} | ||||
| 	}, | ||||
| 	devtool: 'inline-source-map', | ||||
| @@ -13,7 +13,7 @@ const { InjectManifest } = require('workbox-webpack-plugin'); | ||||
| const PUBLIC_URL = process.env.PUBLIC_URL || '/'; | ||||
| 
 | ||||
| module.exports = { | ||||
| 	entry: './frontend/index.tsx', | ||||
| 	entry: './src/frontend/index.tsx', | ||||
| 	output: { | ||||
| 		path: path.resolve(__dirname, 'build'), | ||||
| 		filename: 'assets/app-[fullhash].js', | ||||
| @@ -22,8 +22,8 @@ module.exports = { | ||||
| 	resolve: { | ||||
| 		extensions: ['.js', '.jsx','.ts','.tsx', '.json'], | ||||
| 		alias: { | ||||
| 			'@components': path.resolve(__dirname, 'frontend/components/'), | ||||
| 			'@styles': path.resolve(__dirname, 'frontend/styles/'), | ||||
| 			'@components': path.resolve(__dirname, 'src/frontend/components/'), | ||||
| 			'@styles': path.resolve(__dirname, 'src/frontend/styles/'), | ||||
| 		} | ||||
| 	}, | ||||
| 	mode: 'production', | ||||
| @@ -1,11 +0,0 @@ | ||||
| import fs from 'fs'; | ||||
|  | ||||
| const getHashManifest = () => { | ||||
| 	try { | ||||
| 		return JSON.parse(fs.readFileSync(`${__dirname}/../build/assets/manifest-hash.json`)); | ||||
| 	}catch(err){ | ||||
| 		console.error(err); | ||||
| 	} | ||||
| }; | ||||
|  | ||||
| export default getHashManifest; | ||||
		Reference in New Issue
	
	Block a user