mirror of
https://github.com/aleleba/create-react-ssr.git
synced 2025-01-09 13:36:54 -06:00
PR-753737: Adding final client webpack configuration.
This commit is contained in:
parent
93371d933f
commit
e5ffd7c61d
3
.env.example
Normal file
3
.env.example
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#Port of React App
|
||||||
|
PORT_DEV= #Default Port 3000
|
||||||
|
PORT_RELOAD_DEV= #Default Port PORT_DEV
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,2 +1,6 @@
|
|||||||
#node_modules ignore
|
#node_modules ignore
|
||||||
node_modules
|
node_modules
|
||||||
|
#.envs
|
||||||
|
.env
|
||||||
|
#build
|
||||||
|
/build
|
2184
package-lock.json
generated
2184
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@ -4,9 +4,9 @@
|
|||||||
"description": "Starter Kit de server side render de react",
|
"description": "Starter Kit de server side render de react",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "webpack serve",
|
"start": "webpack serve --config webpack.config.dev.js",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"build": "webpack --mode production"
|
"build": "webpack --config webpack.config.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -23,6 +23,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/aleleba/create-react-ssr#readme",
|
"homepage": "https://github.com/aleleba/create-react-ssr#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"dotenv": "^16.0.0",
|
||||||
"react": "^18.0.0",
|
"react": "^18.0.0",
|
||||||
"react-dom": "^18.0.0"
|
"react-dom": "^18.0.0"
|
||||||
},
|
},
|
||||||
@ -31,8 +32,16 @@
|
|||||||
"@babel/preset-env": "^7.16.11",
|
"@babel/preset-env": "^7.16.11",
|
||||||
"@babel/preset-react": "^7.16.7",
|
"@babel/preset-react": "^7.16.7",
|
||||||
"babel-loader": "^8.2.4",
|
"babel-loader": "^8.2.4",
|
||||||
|
"clean-webpack-plugin": "^4.0.0",
|
||||||
|
"css-loader": "^6.7.1",
|
||||||
|
"css-minimizer-webpack-plugin": "^3.4.1",
|
||||||
"html-loader": "^3.1.0",
|
"html-loader": "^3.1.0",
|
||||||
"html-webpack-plugin": "^5.5.0",
|
"html-webpack-plugin": "^5.5.0",
|
||||||
|
"mini-css-extract-plugin": "^2.6.0",
|
||||||
|
"sass": "^1.50.0",
|
||||||
|
"sass-loader": "^12.6.0",
|
||||||
|
"style-loader": "^3.3.1",
|
||||||
|
"terser-webpack-plugin": "^5.3.1",
|
||||||
"webpack": "^5.72.0",
|
"webpack": "^5.72.0",
|
||||||
"webpack-cli": "^4.9.2",
|
"webpack-cli": "^4.9.2",
|
||||||
"webpack-dev-server": "^4.8.1"
|
"webpack-dev-server": "^4.8.1"
|
||||||
|
8
src/config/index.js
Normal file
8
src/config/index.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
require('dotenv').config();
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
portDev: process.env.PORT_DEV ? process.env.PORT_DEV : 3000,
|
||||||
|
portReloadDev: process.env.PORT_RELOAD_DEV,
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { config: config };
|
@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDom from 'react-dom';
|
import ReactDom from 'react-dom';
|
||||||
import App from './components/App';
|
import App from './components/App';
|
||||||
|
import './styles/global.sass';
|
||||||
|
|
||||||
ReactDom.render(<App />, document.getElementById('app'));
|
ReactDom.render(<App />, document.getElementById('app'));
|
6
src/styles/global.sass
Normal file
6
src/styles/global.sass
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
$base-color: #c6538c
|
||||||
|
$color: rgba(black, 0.88)
|
||||||
|
|
||||||
|
body
|
||||||
|
background-color: $base-color
|
||||||
|
color: $color
|
66
webpack.config.dev.js
Normal file
66
webpack.config.dev.js
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||||
|
const { config: { portDev, portReloadDev } } = require('./src/config')
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entry: './src/index.js',
|
||||||
|
output: {
|
||||||
|
path: path.resolve(__dirname, 'build'),
|
||||||
|
filename: 'bundle.js',
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.js', '.jsx'],
|
||||||
|
},
|
||||||
|
mode: 'development',
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.(js|jsx)$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
use: {
|
||||||
|
loader: 'babel-loader',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.html$/,
|
||||||
|
use: [
|
||||||
|
{ loader: 'html-loader' }
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.s[ac]ss$/,
|
||||||
|
use: [
|
||||||
|
'style-loader',
|
||||||
|
'css-loader',
|
||||||
|
'sass-loader',
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
template: './public/index.html',
|
||||||
|
filename: './index.html',
|
||||||
|
}),
|
||||||
|
new MiniCssExtractPlugin({
|
||||||
|
filename: '[name].css',
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
devServer: {
|
||||||
|
static: {
|
||||||
|
directory: path.join(__dirname, 'dist')
|
||||||
|
},
|
||||||
|
allowedHosts: "all",
|
||||||
|
compress: true,
|
||||||
|
port: portDev,
|
||||||
|
hot: true,
|
||||||
|
client: {
|
||||||
|
reconnect: true,
|
||||||
|
webSocketURL: {
|
||||||
|
port: portReloadDev ? portReloadDev : portDev,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
@ -1,15 +1,25 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||||
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
||||||
|
const TerserPlugin = require('terser-webpack-plugin');
|
||||||
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: './src/index.js',
|
entry: './src/index.js',
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, 'dist'),
|
path: path.resolve(__dirname, 'build'),
|
||||||
filename: 'bundle.js'
|
filename: 'bundle.js',
|
||||||
|
publicPath: '/',
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.js', '.jsx']
|
extensions: ['.js', '.jsx'],
|
||||||
|
alias: {
|
||||||
|
'@components': path.resolve(__dirname, 'src/components/'),
|
||||||
|
'@styles': path.resolve(__dirname, 'src/styles/'),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
mode: 'production',
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
@ -17,28 +27,39 @@ module.exports = {
|
|||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
use: {
|
use: {
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.html$/,
|
test: /\.html$/,
|
||||||
use: [
|
use: [
|
||||||
{ loader: 'html-loader' }
|
{ loader: 'html-loader' }
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
]
|
{
|
||||||
|
test: /\.s[ac]ss$/,
|
||||||
|
use: [
|
||||||
|
'style-loader',
|
||||||
|
'css-loader',
|
||||||
|
'sass-loader',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
template: './public/index.html',
|
template: './public/index.html',
|
||||||
filename: './index.html'
|
filename: './index.html'
|
||||||
})
|
}),
|
||||||
|
new MiniCssExtractPlugin({
|
||||||
|
filename: '[name].css'
|
||||||
|
}),
|
||||||
|
new CleanWebpackPlugin(),
|
||||||
],
|
],
|
||||||
devServer: {
|
optimization: {
|
||||||
static: {
|
minimize: true,
|
||||||
directory: path.join(__dirname, 'dist')
|
minimizer: [
|
||||||
},
|
new CssMinimizerPlugin(),
|
||||||
allowedHosts: "all",
|
new TerserPlugin(),
|
||||||
compress: true,
|
],
|
||||||
port: 3000
|
},
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user