Juan R Labrada

How to use webpack

How to create the simplest config for Webpack

// webpack.config.js
const path = require('path');

module.exports = {
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js',
<!-- page.html -->
<!DOCTYPE html>
    <meta charset="utf-8" />
    <script src="dist/bundle.js"></script>
// src/index.js
import bar from './bar.js';
// src/bar.js
export default function bar() {

Webpack follows the javascript dependency tree starting from the entry file in the config and puts the final bundle file in the output path with the given file name.

© 2023