npm init
git init
yarn add react react-dom
yarn add webpack webpack-cli --dev
yarn add webpack-dev-server --dev
webpack.config.js
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "build"),
filename: "status/js/[name].[contenthash:8].js",
clean: true,
},
resolve: {
extensions: [".js", ".json", ".jsx", ".wasm"],
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
module: {
rules: [
{
test: /\.jsx?$/i,
exclude: /node_modules/,
use: "babel-loader",
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: "./public/index.html",
}),
],
};
yarn add @babel/core @babel/cli
yarn add @babel/preset-env --dev
对 React 的预设
yarn add @babel/preset-react -dev
yarn add babel-loader --dev
babel.config.js
module.exports = {
presets: ["@babel/preset-env", "@babel/preset-react"],
};
.browerslistrc
>1%
last 2 versions
not dead
yarn add eslint --dev
生成配置文件
npm init @eslint/config
# or
yarn create @eslint/config