@umijs/bundler-webpack 4.0.0-canary.20220624.1 → 4.0.0-canary.20220628.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,9 +14,6 @@ async function addAssetRules(opts) {
14
14
  dataUrlCondition: {
15
15
  maxSize: inlineLimit,
16
16
  },
17
- })
18
- .generator({
19
- filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
20
17
  });
21
18
  rule
22
19
  .oneOf('image')
@@ -26,9 +23,6 @@ async function addAssetRules(opts) {
26
23
  dataUrlCondition: {
27
24
  maxSize: inlineLimit,
28
25
  },
29
- })
30
- .generator({
31
- filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
32
26
  });
33
27
  const fallback = rule
34
28
  .oneOf('fallback')
@@ -40,11 +34,6 @@ async function addAssetRules(opts) {
40
34
  if (userConfig.mdx) {
41
35
  fallback.add(/\.mdx?$/);
42
36
  }
43
- fallback
44
- .end()
45
- .type('asset/resource')
46
- .generator({
47
- filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
48
- });
37
+ fallback.end().type('asset/resource');
49
38
  }
50
39
  exports.addAssetRules = addAssetRules;
@@ -78,7 +78,8 @@ async function getConfig(opts) {
78
78
  .filename(useHash ? `[name].[contenthash:8].js` : `[name].js`)
79
79
  .chunkFilename(useHash ? `[name].[contenthash:8].async.js` : `[name].async.js`)
80
80
  .publicPath(userConfig.publicPath || 'auto')
81
- .pathinfo(isDev || disableCompress);
81
+ .pathinfo(isDev || disableCompress)
82
+ .set('assetModuleFilename', `${applyOpts.staticPathPrefix}[name].[hash:8][ext]`);
82
83
  // resolve
83
84
  // prettier-ignore
84
85
  config.resolve
@@ -4,23 +4,20 @@ exports.addCopyPlugin = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const path_1 = require("path");
6
6
  async function addCopyPlugin(opts) {
7
+ var _a;
7
8
  const { config, userConfig, cwd } = opts;
8
9
  const copyPatterns = [
9
10
  (0, fs_1.existsSync)((0, path_1.join)(cwd, 'public')) && {
10
11
  from: (0, path_1.join)(cwd, 'public'),
11
12
  },
12
13
  ...(userConfig.copy
13
- ? userConfig.copy.map((item) => {
14
- if (typeof item === 'string') {
15
- return {
16
- from: (0, path_1.join)(cwd, item),
17
- to: item,
18
- };
14
+ ? (_a = userConfig.copy) === null || _a === void 0 ? void 0 : _a.map((pattern) => {
15
+ if (typeof pattern === 'string') {
16
+ return (0, path_1.resolve)(cwd, pattern);
19
17
  }
20
18
  return {
21
- // 相对于 process.cwd,所以这里需要使用绝对路径
22
- from: (0, path_1.join)(cwd, item.from),
23
- to: item.to,
19
+ from: (0, path_1.resolve)(cwd, pattern.from),
20
+ to: (0, path_1.resolve)(cwd, pattern.to),
24
21
  };
25
22
  })
26
23
  : []),
@@ -35,20 +35,14 @@ async function addSVGRules(opts) {
35
35
  .loader(require.resolve('@umijs/bundler-webpack/compiled/url-loader'))
36
36
  .end();
37
37
  }
38
- if (svgo === false) {
38
+ if (svgo !== false) {
39
39
  const svgRule = config.module.rule('svg');
40
40
  svgRule
41
41
  .test(/\.svg$/)
42
- .use('url-loader')
43
- .loader(require.resolve('@umijs/bundler-webpack/compiled/url-loader'));
44
- return;
42
+ .use('svgo-loader')
43
+ .loader(require.resolve('@umijs/bundler-webpack/compiled/svgo-loader'))
44
+ .options({ configFile: false, ...svgo })
45
+ .end();
45
46
  }
46
- const svgRule = config.module.rule('svg');
47
- svgRule
48
- .test(/\.svg$/)
49
- .use('svgo-loader')
50
- .loader(require.resolve('@umijs/bundler-webpack/compiled/svgo-loader'))
51
- .options({ configFile: false, ...svgo })
52
- .end();
53
47
  }
54
48
  exports.addSVGRules = addSVGRules;
package/dist/dev.js CHANGED
@@ -75,7 +75,7 @@ async function dev(opts) {
75
75
  extraEsbuildLoaderHandler: (mfsu === null || mfsu === void 0 ? void 0 : mfsu.getEsbuildLoaderHandler()) || [],
76
76
  chainWebpack: opts.chainWebpack,
77
77
  modifyWebpackConfig: opts.modifyWebpackConfig,
78
- hmr: true,
78
+ hmr: process.env.HMR !== 'none',
79
79
  analyze: process.env.ANALYZE,
80
80
  cache: opts.cache,
81
81
  });
@@ -138,10 +138,11 @@ async function createServer(opts) {
138
138
  app.use(key, (0, http_proxy_middleware_1.createProxyMiddleware)(key, {
139
139
  ...proxy[key],
140
140
  // Add x-real-url in response header
141
- onProxyRes(proxyRes, req) {
142
- var _a;
141
+ onProxyRes(proxyRes, req, res) {
142
+ var _a, _b;
143
143
  proxyRes.headers['x-real-url'] =
144
144
  ((_a = new URL(req.url || '', target)) === null || _a === void 0 ? void 0 : _a.href) || '';
145
+ (_b = proxyConfig.onProxyRes) === null || _b === void 0 ? void 0 : _b.call(proxyConfig, proxyRes, req, res);
145
146
  },
146
147
  }));
147
148
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@umijs/bundler-webpack",
3
- "version": "4.0.0-canary.20220624.1",
3
+ "version": "4.0.0-canary.20220628.1",
4
4
  "description": "@umijs/bundler-webpack",
5
- "homepage": "https://github.com/umijs/umi-next/tree/master/packages/bundler-webpack#readme",
6
- "bugs": "https://github.com/umijs/umi-next/issues",
5
+ "homepage": "https://github.com/umijs/umi/tree/master/packages/bundler-webpack#readme",
6
+ "bugs": "https://github.com/umijs/umi/issues",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/umijs/umi-next"
9
+ "url": "https://github.com/umijs/umi"
10
10
  },
11
11
  "license": "MIT",
12
12
  "main": "dist/index.js",
@@ -35,10 +35,10 @@
35
35
  "@svgr/plugin-jsx": "^6.2.1",
36
36
  "@svgr/plugin-svgo": "^6.2.0",
37
37
  "@types/hapi__joi": "17.1.8",
38
- "@umijs/babel-preset-umi": "4.0.0-canary.20220624.1",
39
- "@umijs/bundler-utils": "4.0.0-canary.20220624.1",
40
- "@umijs/mfsu": "4.0.0-canary.20220624.1",
41
- "@umijs/utils": "4.0.0-canary.20220624.1",
38
+ "@umijs/babel-preset-umi": "4.0.0-canary.20220628.1",
39
+ "@umijs/bundler-utils": "4.0.0-canary.20220628.1",
40
+ "@umijs/mfsu": "4.0.0-canary.20220628.1",
41
+ "@umijs/utils": "4.0.0-canary.20220628.1",
42
42
  "cors": "^2.8.5",
43
43
  "css-loader": "6.7.1",
44
44
  "es5-imcompatible-versions": "^0.1.73",