const path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
entry: './src/index.tsx',
output: {
path: path.resolve(__dirname, 'build'),
filename: 'index.js',
},
devServer: {
contentBase: './build',
historyApiFallback: true,
compress: true,
open: true,
port: 3189,
},
module: {
rules: [
{
test: /\.[tj]sx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.(png|jpe?g|gif|ico)$/i,
use: [
{
loader: 'file-loader',
},
],
},
{
test: /\.(txt|json)$/i,
use: [
{
loader: 'file-loader',
},
],
},
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
],
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html',
filename: 'index.html',
favicon: './public/favicon.ico'
}),
new MiniCssExtractPlugin({
filename: '[name].css',
}),
new CleanWebpackPlugin(),
],
};