Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Better handling of publicPath: 'auto' #7005

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

hansonfang commented Feb 25, 2022

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

AndreiSoroka commented Feb 25, 2022

@hansonfang updated MR

@AndreiSoroka
Copy link
Contributor Author

AndreiSoroka commented Mar 1, 2022

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

@AndreiSoroka
Copy link
Contributor Author

AndreiSoroka commented Mar 1, 2022

FYI: @sodatea ?

@hansonfang
Copy link

hansonfang commented Mar 2, 2022

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

Copy link
Member

@sodatea sodatea left a comment

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

AndreiSoroka commented Mar 2, 2022

thanks. I will update mr on this week

@AndreiSoroka AndreiSoroka requested a review from sodatea Mar 18, 2022
@AndreiSoroka
Copy link
Contributor Author

AndreiSoroka commented Mar 21, 2022

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

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

Successfully merging this pull request may close these issues.

None yet

3 participants