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

[webpack 5] support publicPath: "auto" #1514

Closed
sokra opened this issue Sep 21, 2020 · 3 comments
Closed

[webpack 5] support publicPath: "auto" #1514

sokra opened this issue Sep 21, 2020 · 3 comments

Comments

@sokra
Copy link
Contributor

sokra commented Sep 21, 2020

Expected behaviour

When using the default of publicPath: "auto", html-webpack-plugin should generate a script tag with an URL pointing to the script file.

Current behaviour

<script src="auto/main.js"></script>

Environment

webpack 5.0.0-rc.0
html-webpack-plugin: 4.4.1

Config

Copy the minimal webpack.config.js to produce this issue:

module.exports = {
  plugins: [
    new HtmlWebpackPlugin()
  ]
}

Additional context

webpack has added output.publicPath: "auto". This figures out the correct publicPath at runtime by reading it from the script tag.

html-webpack-plugin should understand this magic value and behave like publicPath: ""

@jantimon
Copy link
Owner

jantimon commented Sep 21, 2020

Is there an API to get the public path?

Right now we use:

/**
* @type {string} the configured public path to the asset root
* if a path publicPath is set in the current webpack config use it otherwise
* fallback to a relative path
*/
const webpackPublicPath = webpackMajorVersion === 4
? compilation.mainTemplate.getPublicPath({ hash: compilationHash })
: compilation.getAssetPath(compilation.outputOptions.publicPath, { hash: compilationHash });

@sokra
Copy link
Contributor Author

sokra commented Sep 22, 2020

fixed by #1516

@FishOrBear
Copy link

@sokra
When using the DllReferencePlugin plugin, there is still a problem of auto.

"auto/xxx.dll.js"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants