├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── LICENSE ├── README.md ├── jest.config.js ├── package-lock.json ├── package.json ├── postcss.config.js ├── src ├── assets │ └── meta.png ├── index.html ├── index.test.ts ├── index.ts └── styles │ └── index.css ├── tailwind.config.js ├── tsconfig.json ├── webpack-prod.config.js └── webpack.config.js /.eslintignore: -------------------------------------------------------------------------------- 1 | dist -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | module.exports = { 3 | env: { 4 | node: true, 5 | jest: true 6 | }, 7 | extends: ['plugin:@typescript-eslint/recommended', 'eslint:recommended'], 8 | parser: '@typescript-eslint/parser', 9 | plugins: ['@typescript-eslint'], 10 | root: true 11 | }; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 CodeWithAhsan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TypeScript Webpack Tailwind CSS Starter 2 | 3 |
4 | 5 |
6 | 7 | Just like any regular day, I was working on something. This time during a Live Stream on [Twitch](https://twitch.tv/CodeWithAhsan) and [YouTube](https://youtube.com/c/CodeWithAhsan) when I couldn't find a great typescript + webpack starter template that's minimal, up to date, and works! So I created this one. 8 | 9 | And here is the accompanied [YouTube Tutorial](https://www.youtube.com/watch?v=2JKGGMD4fXk). 10 | ## Usage 11 | Clone the repository in your local machine. 12 | Run the following command to install the dependencies 13 | ```bash 14 | npm install 15 | # or 16 | yarn 17 | ``` 18 | 19 | Then run the following command to start the dev server: 20 | ```bash 21 | npm start 22 | # OR 23 | yarn start 24 | ``` 25 | 26 | ## Build 27 | To generate the production build, run the following command: 28 | ```bash 29 | npm run build 30 | # OR 31 | yarn build 32 | ``` 33 | 34 | # License 35 | [MIT](LICENSE) -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 2 | module.exports = { 3 | preset: 'ts-jest', 4 | testEnvironment: 'node', 5 | moduleNameMapper: { 6 | "\\.(css|sass)$": "identity-obj-proxy", 7 | }, 8 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typescript-tailwind-webpack-starter", 3 | "version": "1.0.0", 4 | "description": "A modern Webpack 5, Tailwind CSS 3, and TypeScript Web Apps Starter Template", 5 | "private": true, 6 | "scripts": { 7 | "start": "webpack serve --mode=development --open", 8 | "build": "webpack --config webpack-prod.config.js", 9 | "test": "jest", 10 | "lint": "eslint ./src/**/*.ts", 11 | "test:watch": "jest --watch" 12 | }, 13 | "keywords": [], 14 | "author": "Muhammad Ahsan Ayaz", 15 | "license": "MIT", 16 | "devDependencies": { 17 | "@types/jest": "^29.5.4", 18 | "@typescript-eslint/eslint-plugin": "^6.5.0", 19 | "@typescript-eslint/parser": "^6.5.0", 20 | "copy-webpack-plugin": "^10.1.0", 21 | "css-loader": "^6.5.1", 22 | "eslint": "^8.48.0", 23 | "html-webpack-plugin": "^5.5.0", 24 | "identity-obj-proxy": "^3.0.0", 25 | "jest": "^29.6.4", 26 | "postcss": "^8.4.4", 27 | "postcss-loader": "^6.2.1", 28 | "postcss-preset-env": "^7.0.1", 29 | "style-loader": "^3.3.1", 30 | "tailwindcss": "^3.0.1", 31 | "ts-jest": "^29.1.1", 32 | "ts-loader": "^9.4.4", 33 | "typescript": "^5.2.2", 34 | "webpack": "^5.65.0", 35 | "webpack-cli": "^4.9.1", 36 | "webpack-dev-server": "^4.6.0" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | const tailwindcss = require("tailwindcss"); 2 | module.exports = { 3 | plugins: ["postcss-preset-env", tailwindcss], 4 | }; 5 | -------------------------------------------------------------------------------- /src/assets/meta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhsanAyaz/typescript-tailwind-webpack-starter/88ddd5d4b9f48ba3c3751551cde62b639c77526d/src/assets/meta.png -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 |

11 | TypeScript Webpack Tailwind CSS Starter 12 | Code With Ahsan 13 |

14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/index.test.ts: -------------------------------------------------------------------------------- 1 | import { greet } from "./index" 2 | 3 | describe('greeter', () => { 4 | it('should return the message from the method', () => { 5 | const message = greet(); 6 | expect(message).toBe('Hello World from Code with Ahsan!') 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import "./styles/index.css"; 2 | 3 | export const greet = () => { 4 | return "Hello World from Code with Ahsan!"; 5 | } 6 | 7 | const main = () => { 8 | console.log(greet()); 9 | }; 10 | 11 | main(); 12 | -------------------------------------------------------------------------------- /src/styles/index.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | body { 6 | } 7 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | content: ["./src/**/*.html", "./src/**/*.{js,jsx,ts,tsx}"], 3 | darkMode: "media", 4 | theme: { 5 | extend: { 6 | colors: { 7 | transparent: "transparent", 8 | current: "currentColor", 9 | "light-grey": "#E5EEE5", 10 | purple: "#7652C6", 11 | }, 12 | }, 13 | }, 14 | variants: { 15 | extend: {}, 16 | }, 17 | plugins: [], 18 | }; 19 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist/", 4 | "sourceMap": true, 5 | "noImplicitAny": true, 6 | "module": "es6", 7 | "target": "es5", 8 | "jsx": "react", 9 | "allowJs": true, 10 | "moduleResolution": "node" 11 | } 12 | } -------------------------------------------------------------------------------- /webpack-prod.config.js: -------------------------------------------------------------------------------- 1 | const config = require("./webpack.config"); 2 | 3 | module.exports = { 4 | ...config, 5 | mode: "production", 6 | }; 7 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const CopyPlugin = require("copy-webpack-plugin"); 3 | 4 | module.exports = { 5 | entry: "./src/index.ts", 6 | mode: "development", 7 | devServer: { 8 | watchFiles: ["src/**/*"], 9 | }, 10 | module: { 11 | rules: [ 12 | { 13 | test: /\.tsx?$/, 14 | use: "ts-loader", 15 | exclude: /node_modules/, 16 | }, 17 | { 18 | test: /\.css$/i, 19 | include: path.resolve(__dirname, "src"), 20 | use: ["style-loader", "css-loader", "postcss-loader"], 21 | }, 22 | ], 23 | }, 24 | resolve: { 25 | extensions: [".tsx", ".ts", ".js"], 26 | }, 27 | plugins: [ 28 | new CopyPlugin({ 29 | patterns: [ 30 | { from: "src/index.html", to: "index.html" }, 31 | { from: "src/assets", to: "assets"} 32 | ], 33 | }), 34 | ], 35 | output: { 36 | filename: "bundle.js", 37 | path: path.resolve(__dirname, "dist"), 38 | clean: true, 39 | }, 40 | }; 41 | --------------------------------------------------------------------------------