const path = require('path'); const { VueLoaderPlugin } = require('vue-loader'); const MiniCssExtractPlugin = require('mini-css-extract-plugin') const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const { resolve } = require('path'); const CleanTerminalPlugin = require('clean-terminal-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin'); module.exports = (env, argv) => { const target = env.target ?? 'hwe'; const mode = argv.mode ?? 'production'; const tsDir = resolve(__dirname, `${target}/ts/`); const ingame_vue = { name: 'ingame_vue', resolve: { extensions: [".ts", ".tsx", ".vue", ".js"], alias: { vue: "@vue/runtime-dom" } }, mode, entry: { v_inheritPoint: `${tsDir}/v_inheritPoint.ts`, v_board: `${tsDir}/v_board.ts`, v_NPCControl: `${tsDir}/v_NPCControl.ts`, }, output: { filename: '[name].js', path: resolve(__dirname, `${target}/dist_js`) }, devtool: 'source-map', optimization: { splitChunks: { cacheGroups: { commons: { test: /[\\/]node_modules[\\/]/, name: 'vendors_vue', priority: -10, chunks: 'all', reuseExistingChunk: true, }, default: { name: 'common_vue', minChunks: 2, priority: -20, chunks: 'all', reuseExistingChunk: true, }, }, }, minimizer: [ new CssMinimizerPlugin(), new TerserPlugin({ terserOptions: { format: { comments: /@license/i, }, }, extractComments: true, }), ], moduleIds: 'deterministic', }, module: { rules: [ //FROM `vue inspect` and some tweaks { test: /\.(ts|tsx)$/, //exclude: /(node_modules)/, use: [ 'babel-loader', { loader: 'ts-loader', options: { transpileOnly: true, appendTsSuffixTo: [ '\\.vue$' ], happyPackMode: false } } ] }, { test: /\.js$/, exclude: /(node_modules)/, use: [ 'babel-loader', ] }, { test: /\.vue$/, loader: 'vue-loader', exclude: /(node_modules)/, options: { hotReload: false, } }, { test: /\.vue\.(s?[ac]ss)$/, use: ['vue-style-loader', 'css-loader', 'sass-loader'] }, { test: /(?