| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 | 
							- // https://umijs.org/config/
 
- import { defineConfig } from 'umi';
 
- const assetDir = "static"
 
- export default defineConfig({
 
-   history: { type: 'hash' }, // 默认是 browse
 
-   // devtool: 'source-map',//正式坏境查看报错使用,假如正式版稳定请关闭
 
-    // map关闭
 
-    devtool: false,
 
-   //新增
 
-   nodeModulesTransform: {
 
-     type: 'none',
 
-     exclude: [],
 
-   },
 
-   chunks: ['vendors', 'umi'],
 
-   chainWebpack: function (config, { env, webpack, createCSSRule }) {
 
-     // 修改js,js chunk文件输出目录
 
-     config.output
 
-       .filename(assetDir + "/js/[name].[contenthash:8].js")
 
-       .chunkFilename(assetDir + "/js/[name].[contenthash:8].chunk.js");
 
-     // 修改css输出目录
 
-     config.plugin("extract-css").tap(() => [
 
-       {
 
-         filename: `${assetDir}/css/[name].[contenthash:8].css`,
 
-         chunkFilename: `${assetDir}/css/[name].[contenthash:8].chunk.css`,
 
-         ignoreOrder: true,
 
-       },
 
-     ]);
 
-     // 修改图片输出目录
 
-     config.module
 
-       .rule("images")
 
-       .test(/\.(png|jpe?g|gif|webp|ico)(\?.*)?$/)
 
-       .use("url-loader")
 
-       .loader(require.resolve("url-loader"))
 
-       .tap((options) => {
 
-         const newOptions = {
 
-           ...options,
 
-           name: assetDir + "/img/[name].[hash:8].[ext]",
 
-           fallback: {
 
-             ...options.fallback,
 
-             options: {
 
-               name: assetDir + "/img/[name].[hash:8].[ext]",
 
-               esModule: false,
 
-             },
 
-           },
 
-         };
 
-         return newOptions;
 
-       });
 
-     // 修改svg输出目录
 
-     // config.module
 
-     //   .rule("svg")
 
-     //   .test(/\.(svg)(\?.*)?$/)
 
-     //   .use("file-loader")
 
-     //   .loader(require.resolve("file-loader"))
 
-     //   .tap((options) => ({
 
-     //     ...options,
 
-     //     name: assetDir + "/img/[name].[hash:8].[ext]",
 
-     //   }));
 
-     // 修改fonts输出目录
 
-     // config.module
 
-     //   .rule("fonts")
 
-     //   .test(/\.(eot|woff|woff2|ttf)(\?.*)?$/)
 
-     //   .use("file-loader")
 
-     //   .loader(require.resolve("file-loader"))
 
-     //   .tap((options) => ({
 
-     //     ...options,
 
-     //     name: assetDir + "/fonts/[name].[hash:8].[ext]",
 
-     //     fallback: {
 
-     //       ...options.fallback,
 
-     //       options: {
 
-     //         name: assetDir + "/img/[name].[hash:8].[ext]",
 
-     //         esModule: false,
 
-     //       },
 
-     //     },
 
-     //   }));
 
-     // // 添加gzip压缩
 
-     // config.when(true, (config) => {
 
-     //   config
 
-     //     .plugin("compression-webpack-plugin")
 
-     //     .use(CompressionWebpackPlugin, [
 
-     //       {
 
-     //         filename: "[path][base].gz",
 
-     //         algorithm: "gzip",
 
-     //         test: new RegExp("\\.(js|css)$"),
 
-     //         threshold: 10240,
 
-     //         minRatio: 0.8,
 
-     //         // deleteOriginalAssets: true//删除源文件
 
-     //       },
 
-     //     ]);
 
-     // });
 
-     //通用插件合并
 
-     config.merge({
 
-       optimization: {
 
-         splitChunks: {
 
-           chunks: 'all',
 
-           minSize: 30000,
 
-           minChunks: 3,
 
-           automaticNameDelimiter: '.',
 
-           cacheGroups: {
 
-             vendor: {
 
-               name: 'vendors',
 
-               test({ resource }: any) {
 
-                 return /[\\/]node_modules[\\/]/.test(resource);
 
-               },
 
-               priority: 10,
 
-             },
 
-           },
 
-         },
 
-       }
 
-     });
 
-   },
 
-   // 出去console.log
 
-   terserOptions: {
 
-     compress: {
 
-       drop_console: true,
 
-     },
 
-   },
 
-   //替换压缩器为 esbuild
 
-   esbuild: {},
 
-   // 不打包组件使用cdn
 
-   externals: {
 
-     // react: 'window.React',
 
-     // 'react-dom': 'window.ReactDOM',
 
-     // antd: 'window.antd',
 
-     // echarts: 'window.echarts',
 
-     // moment: 'window.moment' 
 
-   },
 
-   scripts: [
 
-     // 'https://unpkg.com/react@17/umd/react.production.min.js',
 
-     // "https://unpkg.com/react-dom@17/umd/react-dom.production.min.js",
 
-     // 'https://cdn.bootcdn.net/ajax/libs/moment.js/2.29.1/moment.min.js',
 
-     // 'https://lib.baomitu.com/antd/4.16.2/antd-with-locales.min.js',
 
-     // 'https://lib.baomitu.com/antd/4.16.12/antd.min.js',
 
-     // 'https://cdn.bootcdn.net/ajax/libs/echarts/5.1.2/echarts.min.js',
 
-   ],
 
-   extraBabelPlugins:['transform-remove-console']
 
- });
 
 
  |