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
I updated to Webpack 5, and "auto" appears in URL paths (so they don't work) #1588
Comments
Which html-webpack-plugin version did you use? In the current 5.x branch it should be resolved: https://www.npmjs.com/package/html-webpack-plugin/v/5.0.0-beta.5 |
I tried it on |
@trusktr @serkanyersen Thanks a lot for reporting this bug! I would love to fix it however this codesandbox is using the following dependencies
with the config const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
plugins: [
new HtmlWebpackPlugin({
template: './src/template.ejs'
})
]
}; and generates html without <!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8"/>
<script defer="defer" src="main.js"></script>
</head>
<body>
<div id="root" style="height: 100%"></div>
</body>
</html> So as you can see everything works correctly.. Please fork this sandbox and adjust it to reproduce the bug. |
Thanks @jantimon I tried few things but could not replicate. it's possible that another plug-in I have is not compatible with wp5 and causing this problem. I'll investigate more and let you know if I find anything. |
Okay I'll close it for now please open a new bug ticket if you find out what's causing this strange behaviour |
My reproduction webpack config is fairly minimal: import {DefinePlugin, optimize} from 'webpack'
import * as path from 'path'
import * as HtmlWebpackPlugin from 'html-webpack-plugin'
const outputPath = `dist`
const nodeEnv = {
// ...elided... don't think it matters
}
module.exports = {
entry: './src/index.tsx',
stats: {assets: false},
output: {
path: path.resolve(outputPath),
filename: 'index.js',
// The app won't load without this simple option. Webpack 5 issue: https://github.com/jantimon/html-webpack-plugin/issues/1588
publicPath: '',
},
module: {
rules: [
{test: /\.js$/, use: ['source-map-loader'], enforce: 'pre'},
{test: /\.ts$/, exclude: /node_modules/, use: [{loader: 'ts-loader', options: {transpileOnly: true}}]},
{
test: /\.tsx$/,
exclude: /node_modules/,
use: [{loader: 'babel-loader', options: {presets: ['@babel/preset-react']}}, {loader: 'ts-loader'}],
},
{test: /\.styl$/, use: ['style-loader', 'css-loader', {loader: 'stylus-loader', options: {}}]},
{test: /\.css$/, use: ['style-loader', 'css-loader']},
{test: /\.(jpg|svg|png|eot|ttf|woff|woff2)$/, exclude: [], use: [{loader: 'url-loader', options: {limit: -1}}]},
],
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
fallback: {
fs: false,
util: false,
process: false,
},
alias: {
'@material-ui/core': '@material-ui/core/es',
'@material-ui/icons': '@material-ui/icons/es',
'@material-ui/lab': '@material-ui/lab/es',
'@material-ui/system': '@material-ui/system/es',
'@material-ui/utils': '@material-ui/utils/es',
// Prevent duplicates of @lume/element being included in the output bundle.
'@lume/element': path.resolve('node_modules', '@lume', 'element'),
},
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html',
hash: true,
}),
// ENV
new DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(nodeEnv),
...{
process: 'undefined',
'process.env': '({})',
'process.argv': '([])',
'process.stdout': false,
'process.platform': JSON.stringify(process.platform),
},
'process.browser': 'true',
}),
new optimize.ModuleConcatenationPlugin(),
],
devServer: {
contentBase: outputPath,
host: 'localhost',
port: 8090,
hot: false,
},
}
Versions:
|
are all those alias and loader configurations necessary to reproduce the issue? which html-webpack-plugin version are you using? if you want me to spent my spare time for your please provide at least a reproduction example based on https://codesandbox.io/s/html-webpack-plugin-5x-alpha-d37s2 :) |
Current behaviour 💣
After updating to Webpack 5 (5.16),
auto/
started appearing in my URL paths, so my<script>
tags don't load.Expected behaviour ☀️
Nothing breaks, things load like before.
Reproduction Example 👾
No reproduction, but this gave a hint: #1514
Environment 🖥
N/A
I solved my issue by setting
output.publicPath
to an empty string. It all works fine after that. But I don't think it should be required.The text was updated successfully, but these errors were encountered: