Webpack5 + React + TypeScript + CSS module II

上一版文章

以上一版文章為基礎增強。

Webpack5 + React + TypeScript + CSS modulechevron-right

增強項目

  1. 加入 .env

  2. webpack 5 的 cache 設定

  3. 加入混淆器將高敏感的程式碼混淆。

§ package.json

{
  "name": "react-widgets",
  "version": "0.0.1",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "webpack --mode development --config webpack.config.development.js",
    "build": "webpack --mode production",
    "watch": "webpack --watch --mode development --config webpack.config.development.js",
    "clean": "echo \"Error: no clean specified\" && exit 0",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "private": true,
  "devDependencies": {
    "@babel/core": "^7.22.20",
    "@babel/preset-env": "^7.22.20",
    "@babel/preset-react": "^7.22.15",
    "@types/crypto-js": "^4.2.2",
    "@types/file-saver": "^2.0.7",
    "@types/node": "^16.18.119",
    "@types/react": "^18.3.11",
    "@types/react-dom": "^18.3.1",
    "babel-loader": "^9.1.3",
    "css-loader": "^6.8.1",
    "dotenv-webpack": "^8.1.0",
    "eslint": "^9.13.0",
    "html-webpack-plugin": "^5.5.3",
    "jotai-devtools": "^0.10.1",
    "style-loader": "^3.3.3",
    "terser-webpack-plugin": "^5.3.10",
    "ts-loader": "^9.5.1",
    "typescript": "^5.6.3",
    "webpack": "^5.88.2",
    "webpack-cli": "^5.1.4",
    "webpack-obfuscator": "^3.5.1"
  },
  "dependencies": {
    "@emotion/react": "^11.13.3",
    "@emotion/styled": "^11.13.0",
    "@mui/icons-material": "^5.16.7",
    "@mui/lab": "^5.0.0-alpha.173",
    "@mui/material": "^5.16.7",
    "@mui/x-data-grid": "^7.22.3",
    "@mui/x-date-pickers": "^7.22.0",
    "crypto-js": "^4.2.0",
    "date-fns": "^4.1.0",
    "dompurify": "^3.2.3",
    "file-saver": "^2.0.5",
    "jose": "^5.9.6",
    "jotai": "^2.10.1",
    "notistack": "^2.0.8",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "react-hook-form": "^7.53.1"
  }
}

§ tsconfig.json

§ declaration.d.ts

§ webpack.config.js

§ webpack.config.development.js

§ .env

§ .env.default

(EOF)

Last updated