const path = require('path'); const { VueLoaderPlugin } = require('vue-loader'); const MiniCssExtractPlugin = require('mini-css-extract-plugin') const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const { resolve } = require('path'); module.exports = (env) => { const target = env.target??'hwe'; const ingame = { name: 'ingame', resolve: { extensions: [".js", ".ts", ".tsx"], alias: { '@': resolve(__dirname, `${target}/ts`) } }, entry: { chiefCenter: `${target}/ts/chiefCenter.ts`, inheritPoint: `${target}/ts/inheritPoint.ts`, common: `${target}/ts/common_deprecated.ts`, troop: `${target}/ts/troop.ts`, map: `${target}/ts/map.ts`, install_db: `${target}/ts/install_db.ts`, install: `${target}/ts/install.ts`, battle_simulator: `${target}/ts/battle_simulator.ts`, recent_map: `${target}/ts/recent_map.ts`, processing: `${target}/ts/processing.ts`, select_npc: `${target}/ts/select_npc.ts`, betting: `${target}/ts/betting.ts`, board: `${target}/ts/board.ts`, bossInfo: `${target}/ts/bossInfo.ts`, myPage: `${target}/ts/myPage.ts`, //FORM 입력용, frontend 변경후 제거 defaultSelectCityByMap: '@/defaultSelectCityByMap.ts', defaultSelectNationByMap: '@/defaultSelectNationByMap.ts', colorSelect: '@/colorSelect.ts', recruitCrewForm: '@/recruitCrewForm.ts' }, output: { filename: '[name].js', path: resolve(__dirname, `${target}/js`) }, mode: 'production', devtool: 'source-map', optimization: { splitChunks: { cacheGroups: { commons: { test: /[\\/]node_modules[\\/]/, name: 'vendors', chunks: 'all', }, }, } }, module: { rules: [{ test: /\.(ts|tsx)$/i, exclude: /(node_modules)/, use: [{ loader: 'babel-loader', options: { presets: [ ['@babel/preset-env', { "targets": "> 0.2%, not ie>8, not op_mini all", "useBuiltIns": "usage", "corejs": 3, "modules": false }], '@babel/preset-typescript' ] } }, 'ts-loader'] }, { test: /\.vue$/i, exclude: /(node_modules)/, use: [ 'vue-loader' ] }, { test: /\.css$/i, use: [ MiniCssExtractPlugin.loader, "css-loader", ], }, { test: /\.s[ac]ss$/i, use: [ MiniCssExtractPlugin.loader, "css-loader", "sass-loader", ], }] }, plugins: [ new VueLoaderPlugin(), new MiniCssExtractPlugin({ filename: '../css/[name].css' }), //new BundleAnalyzerPlugin() ], cache: { type: 'filesystem', allowCollectingMemory: true, }, }; const gateway = { name: 'gateway', resolve: { extensions: [".js", ".ts", ".tsx"] }, entry: { 'common': './ts/common_deprecated.ts', 'entrance': './ts/entrance.ts', 'user_info': './ts/user_info.ts', }, output: { filename: '[name].js', path: path.resolve(__dirname, 'js'), }, mode: 'production', devtool: 'source-map', optimization: { splitChunks: { cacheGroups: { commons: { test: /[\\/]node_modules[\\/]/, name: 'vendors', chunks: 'all', }, }, } }, module: { rules: [{ test: /\.(ts|tsx)$/i, exclude: /(node_modules)/, use: { loader: 'babel-loader', options: { presets: [ ['@babel/preset-env', { "targets": "> 0.2%, not ie>8, not op_mini all", "useBuiltIns": "usage", "corejs": 3, "modules": false }], '@babel/preset-typescript' ] } } }, { test: /\.vue$/i, exclude: /(node_modules)/, use: [ { loader: 'vue-loader' } ] }, { test: /\.css$/i, use: [ MiniCssExtractPlugin.loader, "css-loader", ], }, { test: /\.s[ac]ss$/i, use: [ MiniCssExtractPlugin.loader, "css-loader", "sass-loader", ], }] }, plugins: [ new VueLoaderPlugin(), new MiniCssExtractPlugin({ filename: '../css/[name].css' }), //new BundleAnalyzerPlugin() ], cache: { type: 'filesystem', allowCollectingMemory: true, }, }; if(target == 'hwe'){ return [ingame, gateway]; } else{ return [ingame]; } }