Created
January 27, 2022 19:42
-
-
Save Berkays/1c77706ae7dd03fc25710328990cbcf8 to your computer and use it in GitHub Desktop.
Webpack/Typescript/React Starter Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PLACE INSIDE /src folder | |
export function App() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PLACE INSIDE /src folder | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Sample</title> | |
<style> | |
html, | |
body, | |
#app { | |
min-height: 100; | |
height: 100%; | |
margin: 0; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="app"></div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PLACE INSIDE /src folder | |
import ReactDOM from "react-dom"; | |
import { App } from "./App"; | |
const app = document.getElementById("app"); | |
ReactDOM.render(<App />, app); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "sample", | |
"scripts": { | |
"start": "webpack serve --config ./webpack.config.js --mode development" | |
}, | |
"devDependencies": { | |
"@types/react": "^17.0.38", | |
"@types/react-dom": "^17.0.11", | |
"html-webpack-plugin": "^5.5.0", | |
"ts-loader": "^9.2.6", | |
"webpack": "^5.67.0", | |
"webpack-cli": "^4.9.2", | |
"webpack-dev-server": "^4.7.3" | |
}, | |
"dependencies": { | |
"react": "^17.0.2", | |
"react-dom": "^17.0.2", | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"jsx": "react-jsx", | |
"esModuleInterop": true, | |
"noImplicitAny": true, | |
"allowSyntheticDefaultImports": true, | |
"module": "es6", | |
"target": "es5", | |
"moduleResolution": "node" | |
}, | |
"include": [ | |
"src" | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const HTMLWebpackPlugin = require("html-webpack-plugin"); | |
module.exports = { | |
entry: path.resolve(__dirname, './src/index.tsx'), | |
module: { | |
rules: [ | |
{ | |
test: /\.(ts|tsx)$/, | |
exclude: /node_modules/, | |
use: ['ts-loader'], | |
} | |
], | |
}, | |
resolve: { | |
extensions: ['.js', '.jsx', '.ts', '.tsx'], | |
modules: ['src', 'node_modules'], | |
alias: { | |
"react/jsx-dev-runtime": "react/jsx-dev-runtime.js", | |
"react/jsx-runtime": "react/jsx-runtime.js", | |
} | |
}, | |
plugins: [new HTMLWebpackPlugin({ template: "./src/index.html" })], | |
output: { | |
path: path.resolve(__dirname, './dist'), | |
filename: 'bundle.js', | |
}, | |
devServer: { | |
static: { | |
directory: path.join(__dirname, 'dist'), | |
}, | |
open: true | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment