mirror of https://github.com/alibaba/ice.git
fix: add browsers list config to cache key (#6976)
This commit is contained in:
parent
0b4e0ccd6f
commit
b0eb09d509
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
'@ice/webpack-config': patch
|
||||
'@ice/shared-config': patch
|
||||
---
|
||||
|
||||
fix: mark browserslist config to cache key
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import compilationPlugin, { isSupportedFeature, getJsxTransformOptions } from './unPlugins/compilation.js';
|
||||
import compilationPlugin, { isSupportedFeature, getJsxTransformOptions, getSupportedBrowsers } from './unPlugins/compilation.js';
|
||||
import compileExcludes, { SKIP_COMPILE as skipCompilePackages } from './compileExcludes.js';
|
||||
import getCompilerPlugins from './getCompilerPlugins.js';
|
||||
import getDefineVars from './getDefineVars.js';
|
||||
|
|
@ -19,4 +19,5 @@ export {
|
|||
getPostcssOpts,
|
||||
getAliasWithRoot,
|
||||
getDevtoolValue,
|
||||
getSupportedBrowsers,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -262,11 +262,11 @@ export function getJsxTransformOptions({
|
|||
return commonOptions;
|
||||
}
|
||||
|
||||
function getSupportedBrowsers(
|
||||
export function getSupportedBrowsers(
|
||||
dir: string,
|
||||
isDevelopment: boolean,
|
||||
): string[] | undefined {
|
||||
let browsers: any;
|
||||
let browsers: string[];
|
||||
try {
|
||||
browsers = browserslist.loadConfig({
|
||||
path: dir,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import * as path from 'path';
|
||||
import { createRequire } from 'module';
|
||||
import crypto from 'crypto';
|
||||
import fg from 'fast-glob';
|
||||
import ReactRefreshWebpackPlugin from '@ice/bundles/compiled/@pmmmwh/react-refresh-webpack-plugin/lib/index.js';
|
||||
import bundleAnalyzer from '@ice/bundles/compiled/webpack-bundle-analyzer/index.js';
|
||||
|
|
@ -11,7 +12,7 @@ import ESlintPlugin from '@ice/bundles/compiled/eslint-webpack-plugin/index.js';
|
|||
import CopyPlugin from '@ice/bundles/compiled/copy-webpack-plugin/index.js';
|
||||
import type { NormalModule, Compiler, Configuration } from 'webpack';
|
||||
import type webpack from 'webpack';
|
||||
import { compilationPlugin, compileExcludes, getCompilerPlugins, getDefineVars, getAliasWithRoot, getDevtoolValue } from '@ice/shared-config';
|
||||
import { compilationPlugin, compileExcludes, getCompilerPlugins, getDefineVars, getAliasWithRoot, getDevtoolValue, getSupportedBrowsers } from '@ice/shared-config';
|
||||
import type { Config, ModifyWebpackConfig } from '@ice/shared-config/types.js';
|
||||
import configAssets from './config/assets.js';
|
||||
import configCss from './config/css.js';
|
||||
|
|
@ -152,6 +153,8 @@ export function getWebpackConfig(options: GetWebpackConfigOptions): Configuratio
|
|||
module: true,
|
||||
}, minimizerOptions);
|
||||
|
||||
const supportBrowsers = getSupportedBrowsers(rootDir, dev);
|
||||
const browsersMD5 = supportBrowsers ? crypto.createHash('md5').update(supportBrowsers.join('')).digest('hex') : '';
|
||||
const compilation = compilationPlugin({
|
||||
rootDir,
|
||||
cacheDir,
|
||||
|
|
@ -257,7 +260,7 @@ export function getWebpackConfig(options: GetWebpackConfigOptions): Configuratio
|
|||
} as Configuration['optimization'],
|
||||
cache: enableCache ? {
|
||||
type: 'filesystem',
|
||||
version: `${process.env.__ICE_VERSION__}|${userConfigHash}`,
|
||||
version: `${process.env.__ICE_VERSION__}|${userConfigHash}|${browsersMD5}`,
|
||||
buildDependencies: { config: [path.join(rootDir, 'package.json')] },
|
||||
cacheDirectory: path.join(cacheDir, 'webpack'),
|
||||
} : false,
|
||||
|
|
|
|||
Loading…
Reference in New Issue