Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const webpack = require('webpack');
  2. const path = require('path');
  3. const CleanTerminalPlugin = require('clean-terminal-webpack-plugin');
  4.  
  5. let startTime = null;
  6. const plugins = [
  7.     new CleanTerminalPlugin({
  8.         message: "Compiling..."
  9.     }),
  10.  
  11.     {
  12.         apply: compiler => {
  13.             compiler.hooks.beforeCompile.tap('BeforeCompilePlugin', compilation => {
  14.                 startTime = new Date();
  15.             });
  16.         }
  17.     },
  18.  
  19.     {
  20.         apply: (compiler) => {
  21.             compiler.hooks.done.tap('DonePlugin', (compilation) => {
  22.                 let date = new Date();
  23.                 let months = [
  24.                     'Jan', 'Feb', 'Mar',
  25.                     'Apr', 'May', 'Jun',
  26.                     'Jul', 'Aug', 'Sep',
  27.                     'Oct', 'Nov', 'Dec'
  28.                 ];
  29.                 let minutes = date.getMinutes() < 10 ? ("0" + date.getMinutes()) : ("" + date.getMinutes());
  30.                 let timeString = `${date.getDate()} ${months[date.getMonth() - 1]} ${date.getFullYear()} - ${date.getHours()}:${minutes}`;
  31.                 console.log(`Complete [${date - startTime}ms]`);
  32.                 console.log(`[${timeString}]`);
  33.             });
  34.         }
  35.     }
  36. ];
  37.  
  38. module.exports = {
  39.     mode: "production", //process.env.MODE,
  40.  
  41.     entry: {
  42.         index: path.resolve(__dirname, 'src/main.tsx')
  43.     },
  44.  
  45.     module: {
  46.         rules: [
  47.             {
  48.                 test: /\.tsx?$/,
  49.                 use: [
  50.                     {
  51.                         loader: 'ts-loader',
  52.                         options: {
  53.                             transpileOnly: true,
  54.                             experimentalWatchApi: true,
  55.                         },
  56.                     }
  57.                 ],
  58.  
  59.                 //include: path.resolve(__dirname, "src")
  60.             },
  61.  
  62.             /*{ test: /\.css$/i, use: [ 'style-loader', 'css-loader' ] },
  63.             { test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' }*/
  64.         ],
  65.     },
  66.  
  67.     optimization: {
  68.         removeAvailableModules: false,
  69.         removeEmptyChunks: false,
  70.         minimize: false,
  71.         splitChunks: false
  72.     },
  73.  
  74.     resolve: {
  75.         extensions: ['.tsx', '.ts', '.js']
  76.     },
  77.  
  78.     plugins: plugins,
  79.  
  80.     output: {
  81.         //filename: (process.env.MODE == "development") ? '[name].js' : '[name].[chunkhash].js',
  82.         filename: "[name].js",
  83.         pathinfo: false,
  84.         path: path.resolve(__dirname, '../server/public'),
  85.         publicPath: '/'
  86.     },
  87.  
  88.     //watch: process.env.MODE == "development",
  89.     stats: "minimal"
  90. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement