Skip to content

Instantly share code, notes, and snippets.

@jbenner-radham
Last active February 17, 2018 23:35
Show Gist options
  • Select an option

  • Save jbenner-radham/886c9f6eec2703dc56fd5b6ed62486f5 to your computer and use it in GitHub Desktop.

Select an option

Save jbenner-radham/886c9f6eec2703dc56fd5b6ed62486f5 to your computer and use it in GitHub Desktop.
A somewhat minimal webpack config file for JS via Babel, with a dev server and hot module replacement.
'use strict';
const path = require('path');
const webpack = require('webpack');
module.exports = {
/** @see https://webpack.js.org/configuration/entry-context/#entry */
entry: './src/js/index.js',
/** @see https://webpack.js.org/configuration/output/ */
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
/** @see https://webpack.js.org/configuration/dev-server/ */
devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
hot: true,
open: true,
overlay: true,
port: 8080
},
/** @see https://webpack.js.org/configuration/devtool/ */
devtool: 'source-map',
/** @see https://webpack.js.org/configuration/resolve/ */
resolve: {
extensions: ['.js']
},
/** @see https://webpack.js.org/configuration/module/ */
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
presets: ['env']
},
exclude: /node_modules/
}
]
},
/** @see https://webpack.js.org/configuration/plugins/ */
plugins: [
new webpack.HotModuleReplacementPlugin()
]
}
@jbenner-radham
Copy link
Author

Install dependencies via: yarn add --dev babel-core babel-loader babel-preset-env webpack webpack-dev-server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment