Skip to content

Instantly share code, notes, and snippets.

@Tribhuwan-Joshi
Created September 21, 2022 07:20
Show Gist options
  • Save Tribhuwan-Joshi/00a5aa5e09039f8ae19715b71c0bb8ab to your computer and use it in GitHub Desktop.
Save Tribhuwan-Joshi/00a5aa5e09039f8ae19715b71c0bb8ab to your computer and use it in GitHub Desktop.
webpack config with babel , tailwind and eslint
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
experiments: {
topLevelAwait: true,
},
mode: "development",
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js",
clean: true,
assetModuleFilename: "[name][ext]",
},
devServer: {
static: {
directory: path.resolve(__dirname, "dist"),
},
port: 3000,
open: true,
hot: true,
compress: true,
historyApiFallback: true,
},
module: {
rules: [
{
test: /\.css$/i,
include: path.resolve(__dirname, "src"),
use: ["style-loader", "css-loader", "postcss-loader"],
},
{
test: /\.m?js$/,
exclude: /node_module/,
use: {
loader: 'babel-loader',
options: {
present: [
['@babel/preset-env', { targets: "defaults" }]
]
}
}
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: "asset/resource",
},
{
test: /\.(mp3)$/i,
type: "asset",
},
],
},
plugins: [
new HtmlWebpackPlugin({
hash: true,
title: "My Awesome application",
myPageHeader: "Hello World",
template: "src/template.html",
filename: "index.html", // relative to root of the application
}),
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment