Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Webpack & Node 2018 Starter Config
* Inspired by
const webpack = require('webpack');
const path = require('path');
const fs = require('fs');
//Use nodemon to livereload when using webpack --watch.
const NodemonPlugin = require('nodemon-webpack-plugin');
//Ignore node externals when bundling
const nodeExternals = require('webpack-node-externals');
module.exports = {
entry: 'app.js',
//The Banner plugin adds sourcemaps
plugins: [
new NodemonPlugin(),
new webpack.BannerPlugin({banner:'require("source-map-support").install();', raw: true, entryOnly: false })
module: {
//Add babel , and exclude directories that shouldn't be touched by babel. It will read a .babelrc.
rules: [
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader'
//Node options
target: 'node',
output: {
filename: 'app.js',
path: path.resolve(__dirname, 'dist')
externals: nodeExternals(),
devtool: 'sourcemap'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment