Skip to content

Instantly share code, notes, and snippets.

@LUN7
Created January 3, 2021 13:24
Show Gist options
  • Save LUN7/48d4b8a5e64646042ab5c6a507ef245e to your computer and use it in GitHub Desktop.
Save LUN7/48d4b8a5e64646042ab5c6a507ef245e to your computer and use it in GitHub Desktop.
react webpack config
const path = require('path');
const HtmlWebPackPlugin = require('html-webpack-plugin');
module.exports = {
context: path.resolve(__dirname,'src'),
entry: './index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'main.js',
publicPath:'./',
},
devServer: {
contentBase: path.join(__dirname,'dist'),
compress: true,
port:3000,
historyApiFallback: true
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.css$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
},
],
},
],
},
plugins: [
new HtmlWebPackPlugin({
template: path.resolve( __dirname, 'public/index.html'),
filename: 'index.html'
}),
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment