2022-10-13 09:50:30 +02:00
|
|
|
const path = require("path")
|
|
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin")
|
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
mode: "development",
|
|
|
|
entry: {
|
|
|
|
bundle: path.resolve(__dirname, "src", "index.tsx")
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
filename: "[name].[contenthash].js",
|
|
|
|
path: path.resolve(__dirname, "dist")
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.tsx?/,
|
|
|
|
use: 'ts-loader',
|
|
|
|
exclude: /node_modules/
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
include: path.resolve(__dirname, 'src'),
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: [
|
|
|
|
['@babel/preset-env', { "targets": "defaults" }],
|
|
|
|
'@babel/preset-react'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2022-10-13 14:21:45 +02:00
|
|
|
test: /\.scss$/,
|
2022-10-13 09:50:30 +02:00
|
|
|
use: [
|
|
|
|
// Creates `style` nodes from JS strings
|
|
|
|
"style-loader",
|
|
|
|
// Translates CSS into CommonJS
|
|
|
|
"css-loader",
|
|
|
|
// Compiles Sass to CSS
|
|
|
|
"sass-loader",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/i,
|
|
|
|
use: [MiniCssExtractPlugin.loader, "css-loader"],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
resolve: {
|
2022-10-13 14:21:45 +02:00
|
|
|
extensions: [".tsx", ".jsx", ".js", ".css", ".scss"],
|
|
|
|
alias: {
|
|
|
|
"@mui/styles": path.resolve(__dirname, "node_modules", "@mui/styles"),
|
|
|
|
}
|
2022-10-13 09:50:30 +02:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: path.join(__dirname, "src", "html", "template.html"),
|
|
|
|
filename: "index.html",
|
|
|
|
title: "React with Webpack",
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}
|