123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- import { defineConfig } from 'umi';
- const assetDir = "static"
- export default defineConfig({
- history: { type: 'hash' },
-
-
- devtool: false,
-
- nodeModulesTransform: {
- type: 'none',
- exclude: [],
- },
- chunks: ['vendors', 'umi'],
- chainWebpack: function (config, { env, webpack, createCSSRule }) {
-
- config.output
- .filename(assetDir + "/js/[name].[contenthash:8].js")
- .chunkFilename(assetDir + "/js/[name].[contenthash:8].chunk.js");
-
- 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;
- });
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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,
- },
- },
- },
- }
- });
- },
-
- terserOptions: {
- compress: {
- drop_console: true,
- },
- },
-
- esbuild: {},
-
- externals: {
-
-
-
-
-
- },
- scripts: [
-
-
-
-
-
-
- ],
- extraBabelPlugins:['transform-remove-console']
- });
|