SHARE
TWEET

Untitled

a guest Jul 16th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const HtmlWebpackPlugin = require("html-webpack-plugin");
  2. const path = require("path");
  3. const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  4.  
  5. module.exports = {
  6.   entry: { app: "./src/index.js" },
  7.   output: {
  8.     path: path.resolve(__dirname, "dist"),
  9.     filename: "[name].[chunkhash].js",
  10.     publicPath: "/"
  11.   },
  12.   module: {
  13.     rules: [
  14.       {
  15.         test: /.(js|jsx)?$/,
  16.         exclude: /(node_modules|bower_components)/,
  17.         use: {
  18.           loader: "babel-loader",
  19.           options: {
  20.             presets: ["@babel/preset-env", "@babel/preset-react"],
  21.           }
  22.         }
  23.       },
  24.       {
  25.         test: [/.css$/],
  26.         use: [
  27.           "style-loader",
  28.           {
  29.             loader: MiniCssExtractPlugin.loader,
  30.             options: {
  31.               hmr: process.env.NODE_ENV !== "development",
  32.               reloadAll: true
  33.             }
  34.           },
  35.           "css-loader"
  36.         ]
  37.       }
  38.     ]
  39.   },
  40.   plugins: [
  41.     new HtmlWebpackPlugin({
  42.       inject: false,
  43.       template: require("html-webpack-template"),
  44.       hash: true,
  45.       title: "Webpack-tutorial",
  46.       filename: "index.html",
  47.       appMountId: "app-container",
  48.       favicon: "assets/fav.png"
  49.     }),
  50.     new MiniCssExtractPlugin({
  51.       filename: "[name].[contenthash].css"
  52.     })
  53.   ],
  54.   devServer: {
  55.     contentBase: path.resolve(__dirname, "dist"),
  56.     historyApiFallback: true,
  57.     compress: true,
  58.     port: 8080,
  59.     open: "Google Chrome",
  60.     watchContentBase: true,
  61.   }
  62. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top