-
-
Notifications
You must be signed in to change notification settings - Fork 4
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-dev-server: pages require access with .html #27
Comments
Hello @mjlbach, Thank You for the reporting of the issue. P.S. You could greatly speed up the solution of the problem if you created a small repo with a reproducible issue. |
I will help you but I can't reproduce an issue. I have created the example simple multiple pages. Can you please create a small repo based on this example to reproduce a problem. Describe please:
ClarificationEntryThe key of the entry object is the output filename (without entry: {
index: './src/app/home/index.pug', // output ./dist/index.html
people: './src/app/people/index.pug', // output ./dist/people.html
// output a generated HTML file to sub directory
'pages/research': './src/app/research/index.pug', // output ./dist/pages/research.html
}, Outputoutput: {
filename: 'app/[name].bundle.js', // don't define it here, this is the same as Plugin option `js.filename`
path: path.resolve(__dirname, 'dist'),
publicPath: 'auto' // default is always `auto`, can be omited
}, file-loaderNote: the {
test: /font-awesome\/.+\/.+\.(eot|svg|ttf|otf|woff(2)?)(\?v=\d+\.\d+\.\d+)?$/,
type: 'asset/resource',
generator: {
// output filename of fonts
filename: 'assets/fonts/[name][ext][query]',
},
} |
ah, now I understand your problem. According to the Web Standards Specification:
If you need to have a URL as a web path (without entry: {
// define URL: https://example.com (real URL: https://example.com/index.html)
index: 'src/views/home/index.pug', // => dist/index.html
// define URL: https://example.com/contact.html
contact: 'src/views/contact/index.pug', // => dist/contact.html
// define URL: https://example.com/about (real URL: https://example.com/about/index.html)
'about/index': 'src/views/about/index.pug', // => dist/about/index.html
}, |
Ah I had tried this before and thought it was a hack! Good to hear this is the recommended solution :) I was confused because when I build/serve the site with cloudflare (and npx serve) it still works without changing the above, and with our previous setup (using html-webpack-plugin) webpack-dev-server it also worked. Do you know what might have changed? |
It was a "magic" of a web-server (cloudfare has non-standard configuration to allow more flexibility). |
I see. Thanks so much for all of your help! |
Hi!
Thanks for this package, I'm in the process of migrating from
HtmlWebpackPlugin
and using pug-loader from an older website.One issue, is that while in production our website is fine, when using webpack-dev-server all links to our pages (people, research, publications ,etc.) require an
.html
postfix. I'm wondering if I've done something wrong, or if you have suggestions as to what I can try? Do I need to use therewrite
field?My understanding is this should be handled by the magicHtml field https://webpack.js.org/configuration/dev-server/
webpack.common.js
webpack.dev.js
The text was updated successfully, but these errors were encountered: