Last active
February 17, 2018 23:35
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '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() | |
| ] | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install dependencies via:
yarn add --dev babel-core babel-loader babel-preset-env webpack webpack-dev-server.