const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const { VueLoaderPlugin } = require('vue-loader');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCssnanoPlugin = require('@intervolga/optimize-cssnano-plugin');
const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin');

const modules = {
  rules: [
    {
      test: /\.js$/,
      use: {
        loader: 'babel-loader',
        options: {
          presets: [[
            '@babel/preset-env',
            {
              targets: {
                chrome: 68,
              },
            },
          ]],
          comments: false,
          compact: true,
        },
      },
    },
    {
      test: /\.vue$/,
      use: 'vue-loader',
    },
    {
      test: /\.css$/,
      loader: [MiniCssExtractPlugin.loader, 'css-loader'],
    },
    {
      test: /\.styl(us)?$/,
      loader: [MiniCssExtractPlugin.loader, 'css-loader', 'stylus-loader'],
    },
    {
      test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/i,
      use: [{
        loader: 'file-loader',
        options: {
          name: '[name].[ext]',
          outputPath: './fonts',
          publicPath: './fonts',
        },
      }],
    },
  ],
};

const serverConfig = {
  entry: './src/entry/server.js',
  target: 'node',
  mode: 'production',
  output: {
    filename: 'ghmattimysql-server.js',
    path: path.resolve(__dirname, 'dist/ghmattimysql'),
  },
  optimization: {
    minimize: false,
  },
  plugins: [
    new CopyWebpackPlugin([
      { from: 'src/static' },
    ]),
  ],
  module: modules,
};

const clientConfig = {
  entry: './src/entry/client.js',
  target: 'node',
  mode: 'production',
  output: {
    filename: 'ghmattimysql-client.js',
    path: path.resolve(__dirname, 'dist/ghmattimysql'),
  },
  optimization: {
    minimize: true,
  },
  module: modules,
};

const nuiConfig = {
  entry: './src/entry/nui.js',
  mode: 'production',
  output: {
    filename: 'app.js',
    path: path.resolve(__dirname, 'dist/ghmattimysql/ui'),
  },
  optimization: {
    minimize: true,
  },
  externals: {
    moment: 'moment',
  },
  stats: {
    children: false,
    warnings: false,
  },
  module: modules,
  plugins: [
    new VueLoaderPlugin(),
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: './src/ui/template/index.html',
    }),
    new MiniCssExtractPlugin({
      filename: 'app.css',
      chunkFilename: '[id].css',
    }),
    new OptimizeCssnanoPlugin({
      sourceMap: false,
      cssnanoOptions: {
        preset: ['default', {
          mergeLonghand: false,
          cssDeclarationSorter: false,
        }],
      },
    }),
    new VuetifyLoaderPlugin(),
  ],
};

module.exports = [serverConfig, clientConfig, nuiConfig];

@@ -1614,47 +1614,636 @@
 atic
-' %7D,%0A    %5D),%0A  %5D,%0A  module: modules,%0A%7D;
+/ghmattimysql.lua', to: '__resource.lua' %7D,%0A      %7B from: 'src/static/ghmattimysql-server.lua', to: 'ghmattimysql-server.lua' %7D,%0A      %7B from: 'src/static/config.json', to: 'config.json' %7D,%0A    %5D),%0A  %5D,%0A  module: modules,%0A%7D;%0A%0A/* const testConfig = %7B%0A  entry: './src/entry/test.js',%0A  target: 'node',%0A  mode: 'production',%0A  output: %7B%0A    filename: 'test-server.js',%0A    path: path.resolve(__dirname, 'dist/ghmattimysql-test'),%0A  %7D,%0A  optimization: %7B%0A    minimize: false,%0A  %7D,%0A  plugins: %5B%0A    new CopyWebpackPlugin(%5B%0A      %7B from: 'src/static/ghmattimysql-test.lua', to: '__resource.lua' %7D,%0A    %5D),%0A  %5D,%0A  module: modules,%0A%7D; */
 %0A%0Aco
@@ -3372,16 +3372,19 @@
 orts = %5B
+%0A  
 serverCo
@@ -3412,11 +3412,28 @@
 uiConfig
+, // testConfig,%0A
 %5D;%0A

Test resource in the future maybe