Skip to content

Instantly share code, notes, and snippets.

@kjkasi
Created November 9, 2021 15:46
Show Gist options
  • Save kjkasi/6a9b90d479e592b03b6643544ca3dba0 to your computer and use it in GitHub Desktop.
Save kjkasi/6a9b90d479e592b03b6643544ca3dba0 to your computer and use it in GitHub Desktop.
webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
module.exports = {
mode: 'development',
entry: './src/index.js',
devtool: 'inline-source-map',
devServer: {
contentBase: './dist',
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [[
'@babel/preset-env',
{
'corejs': 3,
'useBuiltIns': 'usage',
'debug': true,
'targets': [
'last 2 versions'
]
}],
'@babel/preset-react'
],
plugins: [
'@babel/plugin-proposal-class-properties'
]
}
}
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
}
]
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
title: 'Development',
template: 'src/index.html'
}),
],
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/react',
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment