Skip to content

Instantly share code, notes, and snippets.

@terut
Last active August 15, 2020 07:53
Show Gist options
  • Save terut/4cf86328ff844dac2353bc32626a1c8b to your computer and use it in GitHub Desktop.
Save terut/4cf86328ff844dac2353bc32626a1c8b to your computer and use it in GitHub Desktop.
React minimum environment
$ npm init
$ npm i --no-optional -D webpack webpack-cli typescript ts-loader
$ npm i -S react react-dom @types/react @types/react-dom

Add webpack config to scripts of package.json.

{
  "scripts": {
    "build": "webpack",
    "watch": "webpack -w"
  }
}
{
"compilerOptions": {
"sourceMap": true,
"target": "es5",
"module": "es2015",
"jsx": "react",
"moduleResolution": "node",
"lib": ["es2020", "dom"]
}
}
const path = require("path");
module.exports = {
mode: "development",
entry: "./src/index.tsx",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js",
},
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
},
],
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".json"],
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment