JAVASCRIPT   36
webpack config js
Guest on 26th May 2023 01:03:57 PM


  1. const path = require('path');
  2. const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
  3.  
  4. module.exports = {
  5.     entry: {
  6.         app: './global.js'
  7.     },
  8.     output: {
  9.         path: path.resolve(__dirname, ''),
  10.         filename: './plugin.js'
  11.     },
  12.     // Set watch to true for dev purposes.
  13.     watch: false,
  14.     optimization: {
  15.         minimizer: [
  16.             // Javascript optimizer mainly to minimize js files.
  17.             new UglifyJsPlugin({
  18.                 cache: true,
  19.                 parallel: true,
  20.                 sourceMap: true // Set to true if you want JS source maps.
  21.             }),
  22.         ]
  23.     },
  24.     module: {
  25.         rules: [
  26.             {
  27.                 // Rule to translate ES5 javascript files to ES6.
  28.                 test: /\.js$/,
  29.                 exclude: /node_modules\/(?!(@wiris\/mathtype-html-integration-devkit)\/).*/,
  30.                 use: {
  31.                     loader: 'babel-loader',
  32.                     options: {
  33.                         presets: ['@babel/env']
  34.                     }
  35.                 }
  36.             },
  37.             {
  38.                 test: /\.css$/,
  39.                 use: ['style-loader', 'css-loader']
  40.             },
  41.             {
  42.                 test: /\.(png|jpg|gif)$/i,
  43.                 use: [
  44.                   {
  45.                     loader: 'url-loader',
  46.                     options: {
  47.                       limit: 8192
  48.                     }
  49.                   }
  50.                 ]
  51.             },
  52.             {
  53.                 // For the modal close, minimize, maximize icons
  54.                 test: /\.svg$/,
  55.                 use: [ 'raw-loader' ]
  56.             },
  57.         ]
  58.     },
  59.     stats: {
  60.         colors: true
  61.     }
  62. };

Raw Paste

Login or Register to edit or fork this paste. It's free.