euchre-live

Euchre web-app for the socially distant family
git clone git://git.alexkarle.com/euchre-live.git
Log | Files | Refs | README | LICENSE

webpack.config.js (2990B) [raw]


      1 // Autogenerated by Mojolicious-Plugin-Webpack 0.13 for gloat
      2 const path = require('path');
      3 
      4 const isDev = process.env.NODE_ENV !== 'production';
      5 const outDir = process.env.WEBPACK_OUT_DIR || path.resolve(__dirname, './public/asset');
      6 const sassIncludePaths = (process.env.SASS_INCLUDE_PATHS || '').split(':');
      7 const shareDir = process.env.WEBPACK_SHARE_DIR || './assets';
      8 const sourceMap = process.env.WEBPACK_SOURCE_MAPS ? true : isDev ? true : false;
      9 
     10 const HtmlWebpackPlugin = require('html-webpack-plugin');
     11 const HashOutput = require('webpack-plugin-hash-output');
     12 
     13 const config = {
     14   mode: isDev ? 'development' : 'production',
     15   module: {
     16     rules: []
     17   },
     18   optimization: {
     19     minimizer: []
     20   },
     21   output: {
     22     filename: isDev ? '[name].development.js' : '[name].production.js',
     23     path: outDir
     24   },
     25   plugins: [
     26     new HashOutput(),
     27     new HtmlWebpackPlugin({
     28       cache: true,
     29       filename: './webpack.' + (process.env.WEBPACK_CUSTOM_NAME ? process.env.WEBPACK_CUSTOM_NAME : isDev ? 'development' : 'production') + '.html',
     30       hash: false,
     31       inject: 'head',
     32       minify: false,
     33       showErrors: true,
     34       template: shareDir + '/webpack.html',
     35       xhtml: false
     36     }),
     37   ]
     38 };
     39 
     40 if (process.env.WEBPACK_RULE_FOR_JS) {
     41   const TerserPlugin = require('terser-webpack-plugin');
     42   config.optimization.minimizer.push(new TerserPlugin({cache: true, parallel: true, sourceMap: sourceMap}));
     43   config.module.rules.push({
     44     test: /\.js$/,
     45     exclude: /node_modules/,
     46     use: {
     47       loader: 'babel-loader',
     48       options: {
     49         presets: ['@babel/react'],
     50         plugins: [
     51           '@babel/plugin-proposal-class-properties'
     52         ]
     53       }
     54     }
     55   });
     56 }
     57 
     58 if (process.env.WEBPACK_RULE_FOR_CSS || process.env.WEBPACK_RULE_FOR_SASS) {
     59   var MiniCssExtractPlugin = require('mini-css-extract-plugin');
     60   config.plugins.push(new MiniCssExtractPlugin({
     61     filename: isDev ? '[name].development.css' : '[name].production.css',
     62   }));
     63 
     64   const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
     65   config.optimization.minimizer.push(new OptimizeCSSAssetsPlugin({}));
     66 }
     67 
     68 if (process.env.WEBPACK_RULE_FOR_CSS) {
     69   config.module.rules.push({
     70     test: /\.css$/,
     71     use: [
     72       MiniCssExtractPlugin.loader,
     73       {loader: 'css-loader', options: {sourceMap: true}}
     74     ]
     75   });
     76 }
     77 
     78 if (process.env.WEBPACK_RULE_FOR_SASS) {
     79   config.module.rules.push({
     80     test: /\.s(a|c)ss$/,
     81     use: [
     82       MiniCssExtractPlugin.loader,
     83       {loader: 'css-loader', options: {sourceMap: sourceMap}},
     84       {loader: 'sass-loader', options: {sassOptions: {includePaths: sassIncludePaths}, sourceMap: sourceMap}}
     85     ]
     86   });
     87 }
     88 
     89 if (process.env.WEBPACK_RULE_FOR_VUE) {
     90   const { VueLoaderPlugin } = require('vue-loader')
     91   config.plugins.push(new VueLoaderPlugin());
     92   config.module.rules.push({
     93     test: /\.vue$/,
     94     use: 'vue-loader'
     95   });
     96 }
     97 
     98 require('./assets/webpack.' + (process.env.WEBPACK_CUSTOM_NAME || 'custom') + '.js')(config);
     99 
    100 module.exports = config;