Files
lenssim/webpack.config.js
T

60 lines
1.4 KiB
JavaScript

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = (env, argv) => {
const isProduction = argv.mode === 'production';
return {
entry: './src/index.jsx',
output: {
path: path.resolve(__dirname, 'dist'),
filename: isProduction ? 'static/js/[name].[contenthash].js' : 'static/js/bundle.js',
clean: true,
publicPath: '/',
},
resolve: {
extensions: ['.js', '.jsx'],
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: 'babel-loader',
},
{
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1,
},
},
'postcss-loader',
],
},
{
test: /\.(png|jpg|jpeg|svg|gif)$/i,
type: 'asset/resource',
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'public/index.html'),
}),
],
devtool: isProduction ? 'source-map' : 'eval-source-map',
devServer: {
static: path.resolve(__dirname, 'public'),
historyApiFallback: true,
hot: true,
host: '127.0.0.1',
port: 3000,
open: false,
},
};
};