const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
const CSSModuleLoader = {
loader: "css-loader",
options: {
importLoaders: 2,
sourceMap: true,
modules: {
localIdentName: "[name]_[local]_[hash:base64:5]",
},
},
};
const CSSLoader = {
loader: "css-loader",
options: {
modules: "global",
importLoaders: 2,
sourceMap: true,
},
};
const PostCSSLoader = {
loader: "postcss-loader",
options: {
sourceMap: true,
},
};
const styleLoader = "style-loader";
module.exports = {
entry: "./src/index.tsx",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.[hash].js",
},
devServer: {
compress: true,
port: 8080,
hot: true,
static: "./dist",
historyApiFallback: true,
open: true,
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: { loader: "ts-loader" },
},
{
test: /\.(sa|sc|c)ss$/,
exclude: /\.module\.(sa|sc|c)ss$/,
use: [styleLoader, CSSLoader, PostCSSLoader],
},
{
test: /\.module\.(sa|sc|c)ss$/,
use: [styleLoader, CSSModuleLoader, PostCSSLoader],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: __dirname + "/public/index.html",
filename: "index.html",
}),
],
mode: "development",
devtool: "inline-source-map",
experiments: {
asyncWebAssembly: true,
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
};