Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/skanda890/CodePark
Browse files Browse the repository at this point in the history
  • Loading branch information
skanda890 committed Aug 9, 2024
2 parents 8be28ca + aa03ae4 commit 09ac2d4
Showing 1 changed file with 63 additions and 10 deletions.
73 changes: 63 additions & 10 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,69 @@
const path = require('path');
import path from 'path';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import { DefinePlugin } from 'webpack';

module.exports = {
const isProduction = process.env.NODE_ENV === 'production';

export default {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
path: path.resolve('dist'),
filename: isProduction ? '[name].[contenthash].js' : '[name].js',
publicPath: '/'
},
resolve: {
alias: {
'my-alias': path.resolve(__dirname, 'src/')
},
extensions: ['.js', '.json', '.wasm']
mode: isProduction ? 'production' : 'development',
devtool: isProduction ? 'source-map' : 'eval-source-map',
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
},
{
test: /\.css$/,
use: [
isProduction ? MiniCssExtractPlugin.loader : 'style-loader',
'css-loader',
'postcss-loader'
]
},
{
test: /\.(png|jpg|gif|svg)$/,
type: 'asset/resource'
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
type: 'asset/resource'
}
]
},
mode: 'development'
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: './src/index.html',
minify: isProduction
}),
new MiniCssExtractPlugin({
filename: isProduction ? '[name].[contenthash].css' : '[name].css'
}),
new DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
],
devServer: {
contentBase: path.resolve('dist'),
compress: true,
port: 9000,
historyApiFallback: true,
open: true
},
optimization: {
splitChunks: {
chunks: 'all'
},
runtimeChunk: 'single'
}
};

0 comments on commit 09ac2d4

Please sign in to comment.