Skip to content

Instantly share code, notes, and snippets.

@trooperandz
Last active August 4, 2018 20:24
Show Gist options
  • Save trooperandz/cdf57598e12b87eeb260e6bcc28becc0 to your computer and use it in GitHub Desktop.
Save trooperandz/cdf57598e12b87eeb260e6bcc28becc0 to your computer and use it in GitHub Desktop.
Basic webpack config file for React app from scratch blog post
const path = require('path');
const webpack = require('webpack');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
module.exports = {
entry: './src/index.js',
mode: 'development',
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
options: { presets: ['env'] },
},
],
},
resolve: { extensions: ['*', '.js', '.jsx'] },
output: {
path: path.resolve(__dirname, 'dist/'),
publicPath: '/dist/',
filename: 'bundle.js',
},
devServer: {
contentBase: path.join(__dirname, 'public/'),
port: 3000,
publicPath: 'http://localhost:3000/dist/',
hotOnly: true,
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new BrowserSyncPlugin({
host: 'localhost',
port: 8080,
proxy: 'http://localhost:3000/',
}),
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment