DanieleCalisti

webpack.client.config.js

Aug 24th, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const path = require('path');
  2. const HtmlWebpackPlugin = require('html-webpack-plugin');
  3. const CleanWebpackPlugin = require('clean-webpack-plugin');
  4. const buildDirectory = 'dist';
  5. const outputDirectory = buildDirectory + '/client';
  6. module.exports = {
  7.     mode: 'development',
  8.     entry: './src/client/index.js',
  9.     output: {
  10.         path: path.join(__dirname, outputDirectory),
  11.         filename: 'bundle.js'
  12.     },
  13.     module: {
  14.         rules: [
  15.             {
  16.                 test: /\.js$/,
  17.                 exclude: /node_modules/,
  18.                 use: {
  19.                     loader: 'babel-loader'
  20.                 }
  21.             },
  22.             {
  23.                 test: /\.css$/,
  24.                 use: ['style-loader', 'css-loader']
  25.             }
  26.         ]
  27.     },
  28.     devServer: {
  29.         port: 3000,
  30.         open: true
  31.     },
  32.     plugins: [
  33.         new CleanWebpackPlugin([buildDirectory]),
  34.         new HtmlWebpackPlugin({
  35.             template: './public/index.html'
  36.         })
  37.     ]
  38. };
Add Comment
Please, Sign In to add comment