Init babel, react, html webpack generation etc.

This commit is contained in:
Curt Spark 2024-04-12 10:15:01 +01:00
parent 2c75133a37
commit 8301ccf6eb
8 changed files with 5597 additions and 27 deletions

3
.babelrc Normal file
View File

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

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
node_modules/
dist/main.js
dist/

5551
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,8 +14,20 @@
"author": "Curt Spark",
"license": "GPL-3.0-or-later",
"devDependencies": {
"babel-loader": "^9.1.3",
"css-loader": "^7.1.1",
"html-webpack-plugin": "^5.6.0",
"prettier": "3.2.5",
"style-loader": "^4.0.0",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4"
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.0.4"
},
"dependencies": {
"@babel/core": "^7.24.4",
"@babel/preset-env": "^7.24.4",
"@babel/preset-react": "^7.24.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}

9
src/App.js Normal file
View File

@ -0,0 +1,9 @@
import React from "react";
class App extends React.Component {
render() {
return <div>Welcome to React!</div>;
}
}
export default App;

View File

@ -1,13 +1,11 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
</head>
<body>
<script src="main.js"></script>
<div id="root"></div>
</body>
</html>

View File

@ -1 +1,5 @@
console.log("Hi")
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
ReactDOM.render(<App />, document.getElementById("root"));

35
webpack.config.js Normal file
View File

@ -0,0 +1,35 @@
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
entry: "./src/index.js",
output: {
filename: "main.js",
path: path.resolve(__dirname, "dist"),
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: "babel-loader",
},
{
test: /\css$/,
use: [
{
loader: "style-loader",
},
{
loader: "css-loader",
},
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/index.html",
}),
],
};