zucchetti-sa5/webpack.config.js

65 lines
1.9 KiB
JavaScript
Raw Normal View History

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'
]
}
}
},
{
test: /\.scss$/,
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: {
extensions: [".tsx", ".jsx", ".js", ".css", ".scss"],
alias: {
"@mui/styles": path.resolve(__dirname, "node_modules", "@mui/styles"),
}
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, "src", "html", "template.html"),
filename: "index.html",
title: "React with Webpack",
})
]
}