Skip to content

Instantly share code, notes, and snippets.

@mikoloism
Created June 17, 2021 12:32
Show Gist options
  • Save mikoloism/8520eb9c26a0bd4c997fc39638198ff6 to your computer and use it in GitHub Desktop.
Save mikoloism/8520eb9c26a0bd4c997fc39638198ff6 to your computer and use it in GitHub Desktop.
[config] for webpack and typescript

How config webpack for using typescript

Steps

  • install webpack npm install --save-dev webpack webpack-cli ts-loader
  • install typescript npm install --save-dev typescript

File Structur

  • src/
    • index.ts
  • public/
    • index.html
  • webpack.config.js
const path = require('path');
module.exports = {
entry: './src/index.ts',
module: {
rules: [{
test: /\.ts$/,
use: 'ts-loader',
include: [path.resolve(__dirname, 'src')]
}]
},
resolve: {
extensions: ['.ts', '.js'],
},
output: {
publicPath: 'public',
filename: 'bundle.js',
path: path.resolve(__dirname, 'public' || 'dist' || 'build'),
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment