Skip to content

Instantly share code, notes, and snippets.

@CristianRP
Last active April 19, 2024 15:21
Show Gist options
  • Save CristianRP/cdf42a80fe366a90fadb38b33293b8db to your computer and use it in GitHub Desktop.
Save CristianRP/cdf42a80fe366a90fadb38b33293b8db to your computer and use it in GitHub Desktop.

Revisions

  1. CristianRP revised this gist Apr 19, 2024. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions tsconfig.md
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,21 @@ yarn add [email protected] [email protected] [email protected] html-webpack
    yarn add -D typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin ts-loader
    ```

    ### TS config (tsconfig.json)
    ```json
    {
    "compilerOptions": {
    "outDir": "./dist/",
    "noImplicitAny": true,
    "module": "ESNext",
    "target": "ES2020",
    "jsx": "react",
    "allowJs": true,
    "moduleResolution": "node"
    }
    }
    ```

    ### Basic webpack.config.js

    ```js
  2. CristianRP created this gist Apr 19, 2024.
    48 changes: 48 additions & 0 deletions tsconfig.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    # JS Project Setup with Webpack + TypeScript

    ### Install Webpack dependencies
    ```
    yarn add [email protected] [email protected] [email protected] [email protected] nodemon @faker-js/faker
    ```

    ### Install TS dependencies

    ```
    yarn add -D typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin ts-loader
    ```

    ### Basic webpack.config.js

    ```js
    const path = require('path');
    const HtmlWebpackPlugin = require('html-webpack-plugin');

    module.exports = {
    mode: 'development',
    devServer: {
    port: 8080,
    },
    plugins: [
    new HtmlWebpackPlugin({
    template: './public/index.html',
    })
    ],
    module: {
    rules: [
    {
    test: /\.tsx?$/,
    use: 'ts-loader',
    exclude: /node_modules/,
    },
    ],
    },
    resolve: {
    extensions: ['.tsx', '.ts', '.js'],
    },
    output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
    },
    }

    ```