Advertisement
Guest User

webpack.config

a guest
Sep 19th, 2019
154
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 CopyWebpackPlugin = require('copy-webpack-plugin');
  4. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  5.  
  6. const config = {
  7.     entry: {
  8.       app: './src/app.js'
  9.     },
  10.     output: {
  11.       path: path.resolve(__dirname, 'public'),
  12.       filename: "[name].bundle.js",
  13.     },
  14.     devServer: {
  15.       contentBase: path.join(__dirname,'public'),
  16.       port: 3000,
  17.     },
  18.     plugins: [
  19.         new HtmlWebpackPlugin({
  20.           template: './src/html/index.pug'
  21.         }),
  22.         new CopyWebpackPlugin([
  23.           { from: './src/assets/', to: 'assets/' }
  24.         ]),
  25.         new MiniCssExtractPlugin({
  26.           filename: '/assets/css/style.css',
  27.           chunkFilename: '[id].css',
  28.           ignoreOrder: false, // Enable to remove warnings about conflicting order
  29.         })
  30.     ],
  31.     module: {
  32.         rules: [
  33.             {
  34.               test: /\.pug$/,
  35.               //use: ["pug-loader"],
  36.               loader: 'pug-loader',
  37.               options: {
  38.                 pretty: true
  39.               }
  40.             },
  41.             {
  42.               test: /\.css$/,
  43.               use: [
  44.                 {
  45.                   loader: MiniCssExtractPlugin.loader,
  46.                   options: {
  47.                     publicPath: 'assets/css',
  48.                     //hmr: process.env.NODE_ENV === 'development',
  49.                   },
  50.                 },
  51.                 'css-loader',
  52.               ],
  53.             },
  54.             {
  55.               test: /\.(png|jp(e*)g|svg|gif)$/,
  56.               use: [
  57.                 {
  58.                   loader: "file-loader",
  59.                   options: {
  60.                     name:'[name].[ext]'
  61.                   }
  62.                 },
  63.                 /*{
  64.                   loader: 'url-loader',
  65.                   options: {
  66.                   limit: 8000, // Convert images smaller than 8kb to base64 strings
  67.                     name: 'assets/img/[name].[ext]'
  68.                   }
  69.                 },*/
  70.               ]
  71.             }
  72.         ]
  73.     }
  74.   };
  75.  
  76.   module.exports = (env, argv) => {if (argv.mode === 'development') {}
  77.    if (argv.mode === 'production') {} return config;
  78.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement