chore(webpack-react-babel-prettier): npm run prettier:fix
This commit is contained in:
parent
85057f419b
commit
9011a4c50b
|
@ -0,0 +1 @@
|
||||||
|
TODO
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "es5"
|
||||||
|
}
|
|
@ -3,39 +3,39 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
//path is used to resolve properly across the OS
|
//path is used to resolve properly across the OS
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
module.exports = {
|
module.exports = {
|
||||||
//bundle *.js from this entry point
|
//bundle *.js from this entry point
|
||||||
entry: path.resolve(__dirname, '../src/index.jsx'),
|
entry: path.resolve(__dirname, '../src/index.jsx'),
|
||||||
//create output file to be linked to index.html
|
//create output file to be linked to index.html
|
||||||
output: {
|
output: {
|
||||||
filename: '[name].bundle.js',
|
filename: '[name].bundle.js',
|
||||||
path: path.resolve(__dirname, '../dist'),
|
path: path.resolve(__dirname, '../dist'),
|
||||||
clean: true,
|
clean: true,
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
//test all *.js using babel-loader
|
//test all *.js using babel-loader
|
||||||
//test all *.jsx (e.g. React.js) using babel-loader
|
//test all *.jsx (e.g. React.js) using babel-loader
|
||||||
test: /\.(js|jsx)$/,
|
test: /\.(js|jsx)$/,
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
include: path.resolve(__dirname, '../src'),
|
include: path.resolve(__dirname, '../src'),
|
||||||
use: ['babel-loader'],
|
use: ['babel-loader'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
//test all *.css using style-loader and css-loader
|
//test all *.css using style-loader and css-loader
|
||||||
test: /\.css$/i,
|
test: /\.css$/i,
|
||||||
use: ["style-loader", "css-loader"],
|
use: ['style-loader', 'css-loader'],
|
||||||
},
|
},
|
||||||
]
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
extensions: ['*', '.js', '.jsx'],
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
// create a plugin instance so that you can use it several times anywhere
|
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
title: 'Production',
|
|
||||||
template: path.resolve(__dirname, "../public/index.html")
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: ['*', '.js', '.jsx'],
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
// create a plugin instance so that you can use it several times anywhere
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
title: 'Production',
|
||||||
|
template: path.resolve(__dirname, '../public/index.html'),
|
||||||
|
}),
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,13 +4,13 @@ const { merge } = require('webpack-merge');
|
||||||
const common = require('./webpack.common.js');
|
const common = require('./webpack.common.js');
|
||||||
//merge() calls in the environment-specific configuration to include commons
|
//merge() calls in the environment-specific configuration to include commons
|
||||||
module.exports = merge(common, {
|
module.exports = merge(common, {
|
||||||
//set development mode
|
//set development mode
|
||||||
mode: 'development',
|
mode: 'development',
|
||||||
//enable strong source mapping
|
//enable strong source mapping
|
||||||
devtool: 'inline-source-map',
|
devtool: 'inline-source-map',
|
||||||
devServer: {
|
devServer: {
|
||||||
static: path.resolve(__dirname, '../dist'),
|
static: path.resolve(__dirname, '../dist'),
|
||||||
//When using the HTML5 History API, the index.html page will likely have to be served in place of any 404 responses. Enable devServer.historyApiFallback by setting it to true.
|
//When using the HTML5 History API, the index.html page will likely have to be served in place of any 404 responses. Enable devServer.historyApiFallback by setting it to true.
|
||||||
historyApiFallback: true,
|
historyApiFallback: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const { merge } = require('webpack-merge');
|
const { merge } = require('webpack-merge');
|
||||||
const common = require('./webpack.common.js');
|
const common = require('./webpack.common.js');
|
||||||
module.exports = merge(common, {
|
module.exports = merge(common, {
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
//source maps encouraged in production
|
//source maps encouraged in production
|
||||||
//choose mapping with fairly quick build speed like source-map
|
//choose mapping with fairly quick build speed like source-map
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
});
|
});
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,38 +1,42 @@
|
||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "react-example",
|
"name": "react-example",
|
||||||
"description": "React.js example",
|
"description": "React.js example",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
"webpack"
|
"webpack"
|
||||||
],
|
],
|
||||||
"author": "Software Ingenieur Begerad <dialog@SwIngBe.de>",
|
"author": "Software Ingenieur Begerad <dialog@SwIngBe.de>",
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.17.0"
|
"node": ">=18.17.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "webpack serve --config config/webpack.dev.js",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"build": "webpack --config config/webpack.prod.js"
|
"start": "webpack serve --config config/webpack.dev.js",
|
||||||
},
|
"build": "webpack --config config/webpack.prod.js",
|
||||||
"devDependencies": {
|
"prettier": "prettier src --check",
|
||||||
"@babel/core": "7.23.9",
|
"prettier:fix": "prettier --write \"**/*.+(js|jsx|json|css|md)\""
|
||||||
"@babel/preset-env": "7.23.9",
|
},
|
||||||
"@babel/preset-react": "7.23.3",
|
"devDependencies": {
|
||||||
"babel-loader": "9.1.3",
|
"@babel/core": "7.23.9",
|
||||||
"css-loader": "6.7.3",
|
"@babel/preset-env": "7.23.9",
|
||||||
"html-webpack-plugin": "5.5.3",
|
"@babel/preset-react": "7.23.3",
|
||||||
"style-loader": "3.3.2",
|
"babel-loader": "9.1.3",
|
||||||
"webpack": "5.89.0",
|
"css-loader": "6.7.3",
|
||||||
"webpack-cli": "5.1.4",
|
"html-webpack-plugin": "5.5.3",
|
||||||
"webpack-dev-server": "4.15.1",
|
"prettier": "3.2.5",
|
||||||
"webpack-merge": "5.10.0"
|
"style-loader": "3.3.2",
|
||||||
},
|
"webpack": "5.89.0",
|
||||||
"dependencies": {
|
"webpack-cli": "5.1.4",
|
||||||
"prop-types": "15.8.1",
|
"webpack-dev-server": "4.15.1",
|
||||||
"react": "18.2.0",
|
"webpack-merge": "5.10.0"
|
||||||
"react-dom": "18.2.0"
|
},
|
||||||
}
|
"dependencies": {
|
||||||
|
"prop-types": "15.8.1",
|
||||||
|
"react": "18.2.0",
|
||||||
|
"react-dom": "18.2.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# React.js Example
|
# React.js Example
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
0. [General](#general)
|
0. [General](#general)
|
||||||
1. [Links](#links)
|
1. [Links](#links)
|
||||||
|
|
||||||
|
@ -8,10 +9,10 @@
|
||||||
|
|
||||||
# Links
|
# Links
|
||||||
|
|
||||||
* [React setup with webpack for beginners](https://dev.to/deepanjangh/react-setup-with-webpack-for-beginners-2a8k)
|
- [React setup with webpack for beginners](https://dev.to/deepanjangh/react-setup-with-webpack-for-beginners-2a8k)
|
||||||
* [Production](https://webpack.js.org/guides/production/)
|
- [Production](https://webpack.js.org/guides/production/)
|
||||||
* [Setup Development and Production Environment for React App](https://medium.com/freestoneinfotech/setup-development-and-production-environment-for-react-app-397c4cc9e382)
|
- [Setup Development and Production Environment for React App](https://medium.com/freestoneinfotech/setup-development-and-production-environment-for-react-app-397c4cc9e382)
|
||||||
* [HtmlWebpackPlugin](https://webpack.js.org/plugins/html-webpack-plugin/)
|
- [HtmlWebpackPlugin](https://webpack.js.org/plugins/html-webpack-plugin/)
|
||||||
* [load CSS](https://masteringjs.io/tutorials/webpack/css-loader)
|
- [load CSS](https://masteringjs.io/tutorials/webpack/css-loader)
|
||||||
* [load CSS](https://webpack.js.org/loaders/css-loader/)
|
- [load CSS](https://webpack.js.org/loaders/css-loader/)
|
||||||
* [load CSS](https://blog.jakoblind.no/css-modules-webpack/)
|
- [load CSS](https://blog.jakoblind.no/css-modules-webpack/)
|
||||||
|
|
|
@ -2,16 +2,16 @@ import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
//destructure props
|
//destructure props
|
||||||
const Hello = ({msg}) => {
|
const Hello = ({ msg }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div>{msg}</div>
|
<div>{msg}</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Hello
|
export default Hello;
|
||||||
|
|
||||||
Hello.propTypes = {
|
Hello.propTypes = {
|
||||||
msg: PropTypes.string,
|
msg: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,15 +3,15 @@ import ReactDOM from 'react-dom';
|
||||||
import App from './main';
|
import App from './main';
|
||||||
//TODO remove debugging
|
//TODO remove debugging
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
console.log('development mode');
|
console.log('development mode');
|
||||||
}
|
}
|
||||||
//since react 18
|
//since react 18
|
||||||
import { createRoot } from 'react-dom/client';
|
import { createRoot } from 'react-dom/client';
|
||||||
//create root container
|
//create root container
|
||||||
const root = createRoot(document.getElementById("root"));
|
const root = createRoot(document.getElementById('root'));
|
||||||
//render root app
|
//render root app
|
||||||
root.render(
|
root.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<App />
|
<App />
|
||||||
</React.StrictMode>
|
</React.StrictMode>
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,8 +3,8 @@ import Home from './pages/home';
|
||||||
export default function App() {
|
export default function App() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1>React.js</h1>
|
<h1>React.js</h1>
|
||||||
<Home />
|
<Home />
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
{
|
{
|
||||||
"queries": [
|
"queries": [
|
||||||
{
|
{
|
||||||
"title": "Second hand shops",
|
"title": "Second hand shops",
|
||||||
"query": "https://overpass-api.de/api/interpreter?data=[out:json][timeout:60];relation(62531);map_to_area;nwr[shop=second_hand](area)->.shops;nwr[second_hand=yes](area)->.secondHands;(.shops;.secondHands;);out body center qt;"
|
"query": "https://overpass-api.de/api/interpreter?data=[out:json][timeout:60];relation(62531);map_to_area;nwr[shop=second_hand](area)->.shops;nwr[second_hand=yes](area)->.secondHands;(.shops;.secondHands;);out body center qt;"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Organic bakeries",
|
"title": "Organic bakeries",
|
||||||
"query": "https://overpass-api.de/api/interpreter?data=[out:json][timeout:60];relation(62531);map_to_area;nwr[shop=bakery][organic=yes](area);out body center qt;"
|
"query": "https://overpass-api.de/api/interpreter?data=[out:json][timeout:60];relation(62531);map_to_area;nwr[shop=bakery][organic=yes](area);out body center qt;"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Organic only shops",
|
"title": "Organic only shops",
|
||||||
"query": "https://overpass-api.de/api/interpreter?data=[out:json][timeout:60];relation(62531);map_to_area;nwr[shop][organic=only](area);out body center qt;"
|
"query": "https://overpass-api.de/api/interpreter?data=[out:json][timeout:60];relation(62531);map_to_area;nwr[shop][organic=only](area);out body center qt;"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Public bookcases",
|
"title": "Public bookcases",
|
||||||
"query": "https://overpass-api.de/api/interpreter?data=[out:json][timeout:60];relation(62531);map_to_area;nwr[amenity=public_bookcase](area);out body center qt;"
|
"query": "https://overpass-api.de/api/interpreter?data=[out:json][timeout:60];relation(62531);map_to_area;nwr[amenity=public_bookcase](area);out body center qt;"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,27 +6,26 @@ import '../style.css';
|
||||||
import jsonOsmQuery from '../osm-query.json';
|
import jsonOsmQuery from '../osm-query.json';
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
|
const rryOsmQuery = jsonOsmQuery.queries;
|
||||||
|
|
||||||
const rryOsmQuery = jsonOsmQuery.queries;
|
return (
|
||||||
|
<>
|
||||||
return (
|
<h2>Home</h2>
|
||||||
<>
|
<h3>(React.js Lambda Function Component)</h3>
|
||||||
<h2>Home</h2>
|
<Hello msg="Hello World!" />
|
||||||
<h3>(React.js Lambda Function Component)</h3>
|
<div className="container">
|
||||||
<Hello msg="Hello World!" />
|
|
||||||
<div className='container'>
|
|
||||||
<p>Blog RryOsmQuery</p>
|
<p>Blog RryOsmQuery</p>
|
||||||
<div className='rryOsmQuery'>
|
<div className="rryOsmQuery">
|
||||||
{rryOsmQuery.map((query) => (
|
{rryOsmQuery.map((query) => (
|
||||||
<div className='query' key={query.id}>
|
<div className="query" key={query.id}>
|
||||||
<p className='title'>{query.title}</p>
|
<p className="title">{query.title}</p>
|
||||||
<p className='content'>{query.query}</p>
|
<p className="content">{query.query}</p>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Home
|
export default Home;
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
h1 { color: red; }
|
h1 {
|
||||||
h2 { color: green; }
|
color: red;
|
||||||
h3 { color: blue; }
|
}
|
||||||
|
h2 {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
h3 {
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue