vue-cli icon indicating copy to clipboard operation
vue-cli copied to clipboard

PublicPath notworking when target is lib in webpack5 ModuleFederationPlugin希望cli解决此问题

Open xuebigshuai opened this issue 2 years ago • 2 comments

Version

5.0.4

Environment info

 System:
    OS: Windows 10 10.0.18362
    CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
  Binaries:
    Node: 12.14.0 - C:\Program Files\nodejs\node.EXE
    Yarn: Not Found
    npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 101.0.4951.54
    Edge: Spartan (44.18362.449.0)
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props: ^1.2.1 => 1.2.1
    @vue/babel-helper-vue-transform-on:  1.0.2
    @vue/babel-plugin-jsx:  1.1.1
    @vue/babel-plugin-transform-vue-jsx:  1.2.1
    @vue/babel-preset-app:  5.0.4
    @vue/babel-preset-jsx: ^1.2.4 => 1.2.4
    @vue/babel-sugar-composition-api-inject-h:  1.2.1
    @vue/babel-sugar-composition-api-render-instance:  1.2.4
    @vue/babel-sugar-functional-vue:  1.2.2
    @vue/babel-sugar-inject-h:  1.2.2
    @vue/babel-sugar-v-model:  1.2.3
    @vue/babel-sugar-v-on:  1.2.3
    @vue/cli-overlay:  5.0.4
    @vue/cli-plugin-babel: ^5.0.4 => 5.0.4
    @vue/cli-plugin-eslint: ^5.0.4 => 5.0.4
    @vue/cli-plugin-router:  5.0.4
    @vue/cli-plugin-typescript: ^5.0.4 => 5.0.4
    @vue/cli-plugin-unit-jest: ^5.0.4 => 5.0.4
    @vue/cli-plugin-vuex:  5.0.4
    @vue/cli-service: ^5.0.4 => 5.0.4
    @vue/cli-shared-utils:  5.0.4
    @vue/compiler-core:  3.2.31
    @vue/compiler-dom:  3.2.31
    @vue/compiler-sfc: ^3.2.2 => 3.2.31
    @vue/compiler-ssr:  3.2.31
    @vue/component-compiler-utils:  3.3.0
    @vue/eslint-config-standard: ^5.1.2 => 5.1.2
    @vue/eslint-config-typescript: ^5.0.2 => 5.1.0
    @vue/reactivity-transform:  3.2.31
    @vue/shared:  3.2.31
    @vue/test-utils: ^1.0.3 => 1.3.0
    @vue/vue2-jest: ^27.0.0-alpha.3 => 27.0.0
    @vue/web-component-wrapper:  1.3.0
    eslint-plugin-vue: ^7.9.0 => 7.20.0
    jest-serializer-vue:  2.0.2
    typescript: ~4.5.5 => 4.5.5
    vue: ^2.6.12 => 2.6.14
    vue-class-component: ^7.2.3 => 7.2.6
    vue-eslint-parser: ^8.3.0 => 8.3.0 (7.11.0)
    vue-hot-reload-api:  2.3.4
    vue-loader: ^14.2.4 => 14.2.4 (15.9.8, 17.0.0)
    vue-property-decorator: ^9.1.2 => 9.1.2
    vue-router: ^3.5.1 => 3.5.3
    vue-style-loader:  4.1.3
    vue-template-compiler: ^2.6.11 => 2.6.14
    vue-template-es2015-compiler:  1.9.1
    vue-tsx-support: ^3.2.0 => 3.2.0
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

配置模块联邦,然后执行库打包模式。

What is expected?

模块联邦的入口文件的publicPath为空字符串

What is actually happening?

希望和app模式一样,publicPath能够自动获取,这样在联邦模式下,消费者能够正常使用库模式打包的组件


(PublicPath notworking when target is lib in webpack5 ModuleFederationPlugin) 该issue里提供一种解决方案,是通过写webpack插件实现重新赋值publicPath。这样导致的一个问题—自己要维护好这个插件。

xuebigshuai avatar May 17 '22 11:05 xuebigshuai

const { defineConfig } = require("@vue/cli-service"); module.exports = defineConfig({ publicPath:'/', }) 使用 @vue/cli-service 提供的 defineConfig 帮手函数 可以解决此问题

HuZai avatar Mar 29 '23 08:03 HuZai

我发现有人已经搞好了一些MF的模板,你可以看看 I found that someone has already created some MF templates, you can take a look

https://github.com/module-federation/module-federation-examples

chenbingchang avatar Mar 14 '24 06:03 chenbingchang