arco-design / arco-cli

CLI tool for Arco Design
https://arco.design/docs/material/guide
MIT License
203 stars 76 forks source link

打包发布的时候定义的 webpack 插件无效 #53

Closed lin-mt closed 1 year ago

lin-mt commented 1 year ago

Describe the bug 在开发时需要引入一个插件,我将该插件按照以下方式在 .storybook/main.js 中定义使用:

const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
module.exports = {
  // ...
  webpackFinal: (config) => {
    // ...
    if (!config.plugins) {
      config.plugins = [];
    }
    config.plugins.push(new MonacoWebpackPlugin());
    return config;
  },
};

在开发时,该插件正常生效,打包发布后,该插件无效,目前尝试了在 .config/webpack.config.js 中使用该插件,依然无效:

const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
  const finalConfig = merge(config, {
    output: {
      // ...
    },
    plugins: [new MonacoWebpackPlugin()]
  });

To Reproduce Steps to reproduce the behavior:

Expected behavior 插件正常生效

Screenshots

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

MisterLuffy commented 1 year ago

Webpack 只对 /dist/index.min.js 产物生效,具体构建分工可以看 这里。如果是物料本身依赖了这个 Webpack 插件,我认为应该是由物料的使用方来额外配置插件?

lin-mt commented 1 year ago

应该是吧,已经换了另一种方式实现了~谢谢!