2022-09-01
2266
#typescript
Popoola Temitope
127686
Sep 1, 2022 ⋅ 8 min read

Using webpack with TypeScript

Popoola Temitope I'm a software developer and technical writer. I love learning about new technology and am always ready to share ideas with others.

Recent posts:

net maui 9 blazor

.NET MAUI 9 brings new improvements to Blazor

Developers can take advantage of the latest release of .NET MAUI 9 to build better user experiences that more accurately react and respond to changes in their applications.

Andrew Evans
Jan 30, 2025 ⋅ 6 min read
Implementing React Islands In Static Web Applications

Implementing React Islands in static web applications

React Islands integrates React into legacy codebases, enabling modernization without requiring a complete rewrite.

Nelson Michael
Jan 28, 2025 ⋅ 4 min read

Onlook: A React visual editor

Onlook bridges design and development, integrating design tools into IDEs for seamless collaboration and faster workflows.

Jude Miracle
Jan 27, 2025 ⋅ 8 min read
A Comprehensive Guide To JavaScript Generators

A comprehensive guide to JavaScript generators

JavaScript generators offer a powerful and often overlooked way to handle asynchronous operations, manage state, and process data streams.

Fimber Elemuwa
Jan 24, 2025 ⋅ 8 min read
View all posts

6 Replies to "Using webpack with TypeScript"

  1. Thanks for a great article. I tried to follow this tutorial step-by-steps and discovered several issues with it:

    1. In “Setting up webpack and TypeScript” section you forgot to include ‘npm install webpack-dev-server’ command. You need to install this package either globally or locally, otherwise ‘develop’ script won’t work:

    “scripts”: {
    “develop”: “webpack-dev-server –mode development”,

    }

    2. Speaking about npm scripts, in “Package configuration” section there is an inconsistency in naming the script options: “start”: “webpack-dev-server –mode development”, should be changed for ‘develop’
    3. In ‘Package configuration’ section you need to fix the names of the inputs otherwise your app won’t work (compare to the input names in html template):

    function submitHandler(e: Event) {

    const num1 = document.querySelector(“input[name=’a’]”) as HTMLInputElement;
    const num2 = document.querySelector(“input[name=’b’]”) as HTMLInputElement;

    }

    4. In ‘Bundling CSS with `MiniCSSExtractPlugin` an actual npm command should be `npm install –save-dev mini-css-extract-plugin` (otherwise you are installing css minimiser plugin twice)

    By enabling this fixes I was able to complete your tutorial. I hope this helps and again thanks for your efforts!

  2. Hello everyone, for me to import css file in index.ts file just worked as follows: import ‘./main.css’ and not as your code: import styles “./index.css”. I hope this can help other people. and thanks for the tutorial.

    1. Thanks for catching that small typo! We appreciate your sharp eyes and attention to detail — it should be correct now.

Leave a Reply