@qingtian/qtcli 1.0.6 → 1.0.8-beta.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.
@@ -67,6 +67,11 @@ var qtConfig = envLoader.getQtConfig() || {
67
67
  var baseEntries = ((_a = qtConfig === null || qtConfig === void 0 ? void 0 : qtConfig.webpackConfig) === null || _a === void 0 ? void 0 : _a.entry) || {
68
68
  index: path.resolve(process.cwd(), './src/index.tsx'),
69
69
  };
70
+ // build 模式下优先使用 buildOutput 配置,没有则回退到 output
71
+ // 这样 dev 和 build 可以配置不同的 publicPath 等 output 参数
72
+ var userOutput = ((_b = qtConfig === null || qtConfig === void 0 ? void 0 : qtConfig.webpackConfig) === null || _b === void 0 ? void 0 : _b.output) || {};
73
+ var buildOutput = ((_c = qtConfig === null || qtConfig === void 0 ? void 0 : qtConfig.webpackConfig) === null || _c === void 0 ? void 0 : _c.buildOutput) || {};
74
+ var effectiveOutput = isDev() ? userOutput : __assign(__assign({}, userOutput), buildOutput);
70
75
  // 定义基础配置
71
76
  var config = {
72
77
  entry: baseEntries,
@@ -338,7 +343,7 @@ var config = {
338
343
  },
339
344
  // 根据入口数量动态生成 HtmlWebpackPlugin 实例
340
345
  plugins: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], Object.keys(baseEntries).map(function (name) {
341
- var _a, _b, _c, _d, _e, _f;
346
+ var _a, _b, _c, _d;
342
347
  var entryTemplate = path.resolve(process.cwd(), "./public/".concat(name, ".html"));
343
348
  var fallbackTemplate = path.resolve(process.cwd(), './public/index.html');
344
349
  var template = fs.existsSync(entryTemplate) ? entryTemplate : fallbackTemplate;
@@ -348,13 +353,13 @@ var config = {
348
353
  chunks: [name],
349
354
  inject: true,
350
355
  favicon: path.resolve(process.cwd(), './public/favicon.ico'),
351
- publicPath: ((_b = (_a = qtConfig === null || qtConfig === void 0 ? void 0 : qtConfig.webpackConfig) === null || _a === void 0 ? void 0 : _a.output) === null || _b === void 0 ? void 0 : _b.publicPath) || (envConfig === null || envConfig === void 0 ? void 0 : envConfig.PUBLIC_URL) || '/',
352
- meta: Array.isArray((_d = (_c = qtConfig === null || qtConfig === void 0 ? void 0 : qtConfig.config) === null || _c === void 0 ? void 0 : _c.htmlInject) === null || _d === void 0 ? void 0 : _d.head)
353
- ? (_f = (_e = qtConfig === null || qtConfig === void 0 ? void 0 : qtConfig.config) === null || _e === void 0 ? void 0 : _e.htmlInject) === null || _f === void 0 ? void 0 : _f.head.filter(function (item) { return item.tag === 'meta'; }).map(function (item) { return item.attrs; })
356
+ publicPath: (effectiveOutput === null || effectiveOutput === void 0 ? void 0 : effectiveOutput.publicPath) || (envConfig === null || envConfig === void 0 ? void 0 : envConfig.PUBLIC_URL) || '/',
357
+ meta: Array.isArray((_b = (_a = qtConfig === null || qtConfig === void 0 ? void 0 : qtConfig.config) === null || _a === void 0 ? void 0 : _a.htmlInject) === null || _b === void 0 ? void 0 : _b.head)
358
+ ? (_d = (_c = qtConfig === null || qtConfig === void 0 ? void 0 : qtConfig.config) === null || _c === void 0 ? void 0 : _c.htmlInject) === null || _d === void 0 ? void 0 : _d.head.filter(function (item) { return item.tag === 'meta'; }).map(function (item) { return item.attrs; })
354
359
  : [],
355
360
  });
356
361
  }), true), [
357
- new InterpolateHtmlPlugin(HtmlWebpackPlugin, __assign({ PUBLIC_URL: (envConfig === null || envConfig === void 0 ? void 0 : envConfig.PUBLIC_URL) || ((_c = (_b = qtConfig === null || qtConfig === void 0 ? void 0 : qtConfig.webpackConfig) === null || _b === void 0 ? void 0 : _b.output) === null || _c === void 0 ? void 0 : _c.publicPath) || './' }, (((_e = (_d = qtConfig === null || qtConfig === void 0 ? void 0 : qtConfig.config) === null || _d === void 0 ? void 0 : _d.env) === null || _e === void 0 ? void 0 : _e[process.env.NODE_ENV || 'development']) || {})))
362
+ new InterpolateHtmlPlugin(HtmlWebpackPlugin, __assign({ PUBLIC_URL: (envConfig === null || envConfig === void 0 ? void 0 : envConfig.PUBLIC_URL) || (effectiveOutput === null || effectiveOutput === void 0 ? void 0 : effectiveOutput.publicPath) || './' }, (((_e = (_d = qtConfig === null || qtConfig === void 0 ? void 0 : qtConfig.config) === null || _d === void 0 ? void 0 : _d.env) === null || _e === void 0 ? void 0 : _e[process.env.NODE_ENV || 'development']) || {})))
358
363
  ], false), (Array.isArray((_g = (_f = qtConfig === null || qtConfig === void 0 ? void 0 : qtConfig.config) === null || _f === void 0 ? void 0 : _f.htmlInject) === null || _g === void 0 ? void 0 : _g.head)
359
364
  ? [
360
365
  new HtmlWebpackTagsPlugin({
@@ -415,5 +420,11 @@ var config = {
415
420
  },
416
421
  };
417
422
  // 合并 webpack 配置
418
- var finalConfig = (0, deepMerge_1.deepMerge)(config, qtConfig.webpackConfig || {});
423
+ // buildOutput build 模式下合并到 output,然后从 webpackConfig 中移除 buildOutput 避免污染
424
+ var mergeWebpackConfig = __assign({}, (qtConfig.webpackConfig || {}));
425
+ if (!isDev() && mergeWebpackConfig.buildOutput) {
426
+ mergeWebpackConfig.output = __assign(__assign({}, (mergeWebpackConfig.output || {})), mergeWebpackConfig.buildOutput);
427
+ }
428
+ delete mergeWebpackConfig.buildOutput;
429
+ var finalConfig = (0, deepMerge_1.deepMerge)(config, mergeWebpackConfig);
419
430
  exports.default = finalConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qingtian/qtcli",
3
- "version": "1.0.6",
3
+ "version": "1.0.8-beta.1",
4
4
  "description": "QTCli是一款基于node的前端工程化底座",
5
5
  "homepage": "https://gitee.com/fengrengame/qtnode#readme",
6
6
  "bugs": {
package/dist/favicon.ico DELETED
File without changes