mirror of
https://github.com/aleleba/create-react-ssr.git
synced 2025-01-09 21:46:56 -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:
parent
e12e752a55
commit
ed62a71551
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,9 +1,9 @@
|
|||||||
#node_modules ignore
|
#node_modules ignore
|
||||||
src/node_modules
|
client/node_modules
|
||||||
server/node_modules
|
server/node_modules
|
||||||
#.envs
|
#.envs
|
||||||
src/.env
|
client/.env
|
||||||
server/.env
|
server/.env
|
||||||
#builds
|
#builds
|
||||||
src/build
|
client/build
|
||||||
server/build
|
server/build
|
@ -2,10 +2,10 @@
|
|||||||
"name": "create-react-ssr",
|
"name": "create-react-ssr",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Starter Kit de server side render de react",
|
"description": "Starter Kit de server side render de react",
|
||||||
"main": "index.js",
|
"main": "src/server/index",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "ts-node server",
|
"start": "ts-node src/server",
|
||||||
"start:dev": "nodemon --exec 'ts-node' server/index -e js,json,ts,tsx,jsx",
|
"start:dev": "nodemon --exec 'ts-node' src/server/index -e js,json,ts,tsx,jsx",
|
||||||
"build": "webpack-cli --config webpack.config.js",
|
"build": "webpack-cli --config webpack.config.js",
|
||||||
"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",
|
@ -6,11 +6,11 @@ import { BrowserRouter as Router } from 'react-router-dom';
|
|||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import { IInitialState } from './reducers/index.js';
|
import { IInitialState } from './reducers/index.js';
|
||||||
import setStore from './setStore.js';
|
import setStore from './setStore.js';
|
||||||
import { config } from '../config';
|
import { config } from '../../config';
|
||||||
|
|
||||||
import './styles/global.sass';
|
import './styles/global.sass';
|
||||||
import App from './components/App';
|
import App from './components/App';
|
||||||
import serviceWorkerRegistration from '../serviceWorkerRegistration';
|
import serviceWorkerRegistration from '../../serviceWorkerRegistration';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
@ -2,7 +2,7 @@
|
|||||||
import { createStore } from 'redux'; //, applyMiddleware
|
import { createStore } from 'redux'; //, applyMiddleware
|
||||||
// import { Provider } from 'react-redux';
|
// import { Provider } from 'react-redux';
|
||||||
import { composeWithDevTools as composeWithDevToolsWeb } from 'redux-devtools-extension';
|
import { composeWithDevTools as composeWithDevToolsWeb } from 'redux-devtools-extension';
|
||||||
import { config } from '../config';
|
import { config } from '../../config';
|
||||||
import reducer from './reducers';
|
import reducer from './reducers';
|
||||||
|
|
||||||
const { env } = config;
|
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
|
//Dependencies of Server
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { config } from '../config';
|
import { config } from '../../config';
|
||||||
import webpack from 'webpack';
|
import webpack from 'webpack';
|
||||||
import helmet from 'helmet';
|
import helmet from 'helmet';
|
||||||
|
|
||||||
//Dependencies of HotReloading
|
//Dependencies of HotReloading
|
||||||
import webpackConfig from '../webpack.config.dev';
|
import webpackConfig from '../../webpack.config.dev';
|
||||||
import webpackDevMiddleware from 'webpack-dev-middleware';
|
import webpackDevMiddleware from 'webpack-dev-middleware';
|
||||||
import webpackHotMiddleware from 'webpack-hot-middleware';
|
import webpackHotMiddleware from 'webpack-hot-middleware';
|
||||||
|
|
||||||
@ -44,12 +44,14 @@ if(env === 'development'){
|
|||||||
heartbeat: 1000,
|
heartbeat: 1000,
|
||||||
}));
|
}));
|
||||||
}else{
|
}else{
|
||||||
|
const baseUrl = __dirname.replace(/\/client(.*)/,'');
|
||||||
|
const fullURL = `${baseUrl}/client/build` ;
|
||||||
app
|
app
|
||||||
.use((req, res, next) => {
|
.use((req, res, next) => {
|
||||||
if(!req.hashManifest) req.hashManifest = getHashManifest();
|
if(!req.hashManifest) req.hashManifest = getHashManifest();
|
||||||
next();
|
next();
|
||||||
})
|
})
|
||||||
.use(express.static(`${__dirname}/../build`))
|
.use(express.static(fullURL))
|
||||||
.use(helmet())
|
.use(helmet())
|
||||||
.use(helmet.permittedCrossDomainPolicies())
|
.use(helmet.permittedCrossDomainPolicies())
|
||||||
.use(helmet({
|
.use(helmet({
|
@ -7,7 +7,7 @@ const ESLintPlugin = require('eslint-webpack-plugin');
|
|||||||
const PUBLIC_URL = process.env.PUBLIC_URL || '/';
|
const PUBLIC_URL = process.env.PUBLIC_URL || '/';
|
||||||
|
|
||||||
module.exports = {
|
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: {
|
output: {
|
||||||
path: path.resolve(__dirname, 'build'),
|
path: path.resolve(__dirname, 'build'),
|
||||||
filename: 'assets/app.js',
|
filename: 'assets/app.js',
|
||||||
@ -16,8 +16,8 @@ module.exports = {
|
|||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.js', '.jsx','.ts','.tsx', '.json'],
|
extensions: ['.js', '.jsx','.ts','.tsx', '.json'],
|
||||||
alias: {
|
alias: {
|
||||||
'@components': path.resolve(__dirname, 'frontend/components/'),
|
'@components': path.resolve(__dirname, 'src/frontend/components/'),
|
||||||
'@styles': path.resolve(__dirname, 'frontend/styles/'),
|
'@styles': path.resolve(__dirname, 'src/frontend/styles/'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
devtool: 'inline-source-map',
|
devtool: 'inline-source-map',
|
@ -13,7 +13,7 @@ const { InjectManifest } = require('workbox-webpack-plugin');
|
|||||||
const PUBLIC_URL = process.env.PUBLIC_URL || '/';
|
const PUBLIC_URL = process.env.PUBLIC_URL || '/';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: './frontend/index.tsx',
|
entry: './src/frontend/index.tsx',
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, 'build'),
|
path: path.resolve(__dirname, 'build'),
|
||||||
filename: 'assets/app-[fullhash].js',
|
filename: 'assets/app-[fullhash].js',
|
||||||
@ -22,8 +22,8 @@ module.exports = {
|
|||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.js', '.jsx','.ts','.tsx', '.json'],
|
extensions: ['.js', '.jsx','.ts','.tsx', '.json'],
|
||||||
alias: {
|
alias: {
|
||||||
'@components': path.resolve(__dirname, 'frontend/components/'),
|
'@components': path.resolve(__dirname, 'src/frontend/components/'),
|
||||||
'@styles': path.resolve(__dirname, 'frontend/styles/'),
|
'@styles': path.resolve(__dirname, 'src/frontend/styles/'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mode: 'production',
|
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;
|
|
Loading…
Reference in New Issue
Block a user