Last active
May 19, 2024 17:42
-
-
Save rbk/1db21170746ad8e7b2a3f317963011fa to your computer and use it in GitHub Desktop.
2024 - Full webpack.config.js I am using for a side project. (to share on SO)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const TerserPlugin = require("terser-webpack-plugin"); | |
module.exports = { | |
mode: 'development', | |
watchOptions: { | |
ignored: /node_modules/, | |
}, | |
optimization: { | |
minimize: true, | |
minimizer: [ | |
new TerserPlugin({ | |
test: /\.js(\?.*)?$/i, | |
include: /\/src/, | |
}) | |
], | |
}, | |
plugins: [], | |
cache: true, | |
devServer: { | |
liveReload: true, | |
static: { | |
directory: path.join(__dirname, 'public'), | |
}, | |
compress: false, | |
port: 9000, | |
historyApiFallback: true, | |
}, | |
stats: {all: undefined}, | |
resolve: { | |
alias: { | |
}, | |
}, | |
entry: { | |
app: './src/index.js' | |
}, | |
devtool: 'inline-source-map', | |
output: { | |
filename: '[name].bundle.js', | |
path: path.resolve(__dirname, './src/public/bundle'), | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
loader: 'babel-loader', | |
exclude: /node_modules/, | |
include: path.resolve(__dirname, 'src') | |
}, | |
{ | |
test: /\.(png|jpe?g|gif)$/i, | |
exclude: /node_modules/, | |
use: [ | |
{ | |
loader: 'file-loader', | |
options: {outputPath: 'images'} | |
}, | |
], | |
}, | |
{ | |
test: /\.(css|sass|scss)$/, | |
exclude: /node_modules/, | |
use: [ | |
"style-loader", | |
'css-loader', | |
'sass-loader' | |
] | |
} | |
] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's my package.json too: