Skip to content

Better handling of publicPath: 'auto' #7005

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 7 commits into from
Mar 22, 2022
Merged

Conversation

AndreiSoroka
Copy link
Contributor

@AndreiSoroka AndreiSoroka commented Feb 21, 2022

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Underlying tools
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Other information:

For module-federation need to use output auto

const { defineConfig } = require('@vue/cli-service')
const webpack = require('webpack')

module.exports = defineConfig({
  configureWebpack: {
    output: {
      publicPath: 'auto', // <- ERROR: Avoid modifying webpack output.publicPath directly. Use the "publicPath" option instead.
    },
    optimization: {
      splitChunks: false,
    },
    plugins: [
      new webpack.container.ModuleFederationPlugin({
        name: 'vue_cli_demo',
        filename: 'remoteEntry.js',
        exposes: {
          './HelloWorld.vue': './src/components/HelloWorld.vue',
        },
        shared: {
          vue: {
            singleton: true,
          },
        },
      }),
    ],
  },
  transpileDependencies: true
})

Fix problem for

after that I'll add example here

For module-federation need to use output auto
```javascript
const { defineConfig } = require('@vue/cli-service')
const webpack = require('webpack')

module.exports = defineConfig({
  configureWebpack: {
    output: {
      publicPath: 'auto', // <- ERROR: Avoid modifying webpack output.publicPath directly. Use the "publicPath" option instead.
    },
    optimization: {
      splitChunks: false,
    },
    plugins: [
      new webpack.container.ModuleFederationPlugin({
        name: 'vue_cli_demo',
        filename: 'remoteEntry.js',
        exposes: {
          './HelloWorld.vue': './src/components/HelloWorld.vue',
        },
        shared: {
          vue: {
            singleton: true,
          },
        },
      }),
    ],
  },
  transpileDependencies: true
})
@AndreiSoroka AndreiSoroka changed the title Fix bug for configureWebpack.output = 'auto' Fix configureWebpack.output for Module-Federation Feb 21, 2022
@hansonfang
Copy link

https://next.cli.vuejs.org/config/#publicpath VueConfig has option for this.

@AndreiSoroka
Copy link
Contributor Author

AndreiSoroka commented Feb 25, 2022

@hansonfang
image
Local: http://localhost:8082/auto

But... I'm checking at the moment, seems MF is working...

Last time it confused me and I went looking for a workaround

@AndreiSoroka
Copy link
Contributor Author

@hansonfang updated MR

@AndreiSoroka
Copy link
Contributor Author

@hansonfang what do you think about current Mr? (after update)

@AndreiSoroka
Copy link
Contributor Author

FYI: @sodatea ?

@hansonfang
Copy link

@AndreiSoroka sorry I'm not member of contributor group. Maybe ask others to determine.

Copy link
Member

@haoqunjiang haoqunjiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.
But I think there are still many places that we need to fix for publicPath: 'auto' to work correctly.

For example, process.env.BASE_URL should be set to '' in this case. So does the baseUrl argument for genHistoryApiFallbackRewrites.

After applying those changes, I think it would be more consistent to replace the options.publicPath here with process.env.BASE_URL, too.

@AndreiSoroka
Copy link
Contributor Author

thanks. I will update mr on this week

@AndreiSoroka
Copy link
Contributor Author

@sodatea Hi, can you re-review the code?

@haoqunjiang haoqunjiang changed the title Fix configureWebpack.output for Module-Federation Better handling of publicPath: 'auto' Mar 22, 2022
@haoqunjiang haoqunjiang merged commit c5cfefb into vuejs:dev Mar 22, 2022
@AndreiSoroka AndreiSoroka deleted the patch-1 branch March 22, 2022 14:11
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants