PR-753737: Empezando a agregar configuración de webpack al proyecto.

This commit is contained in:
Alejandro Lembke Barrientos 2022-04-11 15:25:51 +00:00
parent 3dfc7b1739
commit 93371d933f
9 changed files with 10692 additions and 0 deletions

6
.babelrc Normal file
View File

@ -0,0 +1,6 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
#node_modules ignore
node_modules

11
PRNameGenerator.ts Normal file
View File

@ -0,0 +1,11 @@
const PRName = function () {
let ID = "";
// let characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
let characters = "0123456789";
for ( var i = 0; i < 6; i++ ) {
ID += characters.charAt(Math.floor(Math.random() * 10));
}
return 'PR-'+ID;
};
console.log(PRName())

10567
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

40
package.json Normal file
View File

@ -0,0 +1,40 @@
{
"name": "create-react-ssr",
"version": "1.0.0",
"description": "Starter Kit de server side render de react",
"main": "index.js",
"scripts": {
"start": "webpack serve",
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --mode production"
},
"repository": {
"type": "git",
"url": "git+https://github.com/aleleba/create-react-ssr.git"
},
"keywords": [
"react",
"ssr"
],
"author": "Alejandro Lembke Barrientos",
"license": "MIT",
"bugs": {
"url": "https://github.com/aleleba/create-react-ssr/issues"
},
"homepage": "https://github.com/aleleba/create-react-ssr#readme",
"dependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"devDependencies": {
"@babel/core": "^7.17.9",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"babel-loader": "^8.2.4",
"html-loader": "^3.1.0",
"html-webpack-plugin": "^5.5.0",
"webpack": "^5.72.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.8.1"
}
}

12
public/index.html Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>App</title>
</head>
<body>
<div id="app"></div>
</body>
</html>

5
src/components/App.jsx Normal file
View File

@ -0,0 +1,5 @@
import React from 'react';
const App = () => <h1>Hello React!</h1>
export default App;

5
src/index.js Normal file
View File

@ -0,0 +1,5 @@
import React from 'react';
import ReactDom from 'react-dom';
import App from './components/App';
ReactDom.render(<App />, document.getElementById('app'));

44
webpack.config.js Normal file
View File

@ -0,0 +1,44 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
resolve: {
extensions: ['.js', '.jsx']
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
}
},
{
test: /\.html$/,
use: [
{ loader: 'html-loader' }
]
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html',
filename: './index.html'
})
],
devServer: {
static: {
directory: path.join(__dirname, 'dist')
},
allowedHosts: "all",
compress: true,
port: 3000
}
}