const path = require('path'); module.exports = { webpack: { configure: (webpackConfig) => { // 设置 publicPath // webpackConfig.output.publicPath = 'http://192.168.1.4:8081/'; // These SVGs are consumed as URLs. Bypass SVGR so Babel does not turn large // flag/sprite sources into unnecessary React components first. const oneOf = webpackConfig.module.rules.find(rule => Array.isArray(rule.oneOf))?.oneOf; const svgRuleIndex = oneOf?.findIndex(rule => rule.test?.test?.("icon.svg")); if (svgRuleIndex >= 0) { oneOf.splice(svgRuleIndex, 0, { test: /[\\/]assets[\\/](?:i18n[\\/][^\\/]+|symbol(?:-defs|-mobile))\.svg$/i, type: "asset/resource", }); } // Split existing initial modules into deterministic cacheable files. They are // still loaded before the entry point, so runtime behavior remains unchanged. const initialChunkMaxSize = 1000000; const currentCacheGroups = webpackConfig.optimization.splitChunks?.cacheGroups || {}; webpackConfig.optimization.splitChunks = { ...webpackConfig.optimization.splitChunks, cacheGroups: { ...currentCacheGroups, initialVendors: { test: /[\\/]node_modules[\\/]/, chunks: "initial", enforce: true, maxSize: initialChunkMaxSize, minSize: 0, priority: 30, reuseExistingChunk: true, }, initialApp: { test: module => module.resource?.startsWith(path.resolve(__dirname, "src")), chunks: "initial", enforce: true, maxSize: initialChunkMaxSize, minSize: 0, priority: 20, reuseExistingChunk: true, }, }, }; // 返回修改后的配置 return webpackConfig; }, alias: { '@components': path.resolve(__dirname, 'src/components'), '@ui': path.resolve(__dirname, 'src/ui'), '@pages': path.resolve(__dirname, 'src/pages'), '@assets': path.resolve(__dirname, 'src/assets'), '@styles': path.resolve(__dirname, 'src/styles'), '@db': path.resolve(__dirname, 'src/db'), '@hooks': path.resolve(__dirname, 'src/hooks'), '@layout': path.resolve(__dirname, 'src/layout'), '@fonts': path.resolve(__dirname, 'src/fonts'), '@utils': path.resolve(__dirname, 'src/utils'), '@widgets': path.resolve(__dirname, 'src/widgets'), '@contexts': path.resolve(__dirname, 'src/contexts'), '@constants': path.resolve(__dirname, 'src/constants'), '@features': path.resolve(__dirname, 'src/features'), '@api':path.resolve(__dirname,'src/api'), }, } };