Skip to content

Instantly share code, notes, and snippets.

@Hebilicious
Created January 19, 2018 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hebilicious/fa4fde55171f4ebffa3b93a51e6ab796 to your computer and use it in GitHub Desktop.
Save Hebilicious/fa4fde55171f4ebffa3b93a51e6ab796 to your computer and use it in GitHub Desktop.
Webpack & Node 2018 Starter Config
/**
* Inspired by https://jlongster.com/Backend-Apps-with-Webpack--Part-I
*/
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 https://www.npmjs.com/package/source-map-support
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',
node:{
console:true
},
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