Skip to content

[ice-pkg 插件开发] modifyUserConfig 不符合预期 #626

Description

@fyangstudio

通过 modifyUserConfig 修改 用户配置 ,和直接配置后的 构建产物不同。

方式一 直接配置:

// build.config.mts

import { defineConfig } from "@ice/pkg";

// https://pkg.ice.work/reference/config/
export default defineConfig({
  transform: {
    formats: ["es2017"],
  },
  bundle: {
    polyfill: false,
    formats: ["es2017"],
  },
});

方式二 通过插件修改配置:

// build.config.mts

import { defineConfig } from "@ice/pkg";

// https://pkg.ice.work/reference/config/
export default defineConfig({
  plugins: ["./plugin.mjs"],
});
// ./plugin.mjs
/**
 * @type {import('@ice/pkg').Plugin}
 */
const plugin = (api, options) => {
  const { modifyUserConfig } = api;
  modifyUserConfig("transform", {
    formats: ["es2017"],
  });
  modifyUserConfig("bundle", {
    polyfill: false,
    formats: ["es2017"],
  });
};

export default plugin;

方式一和方式二 构建产物不同,方式二 多构建了 esm 目录产物

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions