-
-
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
Errors don't show the exact location of the error #9
Comments
div= htmlWebpackPlugin.options.title
Could you please create a simple repo with the file |
In this case I am using the default function output. I discovered the problematic code is:
which then goes to the webpack file-loader This code worked with webdiscus 1.4 but broke with 1.6. I think perhaps the version should have been bumped to 2.x? Perhaps 1.6 is doing something funky with |
the error To locate the problem I need more information:
div= htmlWebpackPlugin.options.title
I have created the test case for require fonts. With Webpack 5 it works
html
head
link(rel="preload" href=require('assets/fonts/ibm-plex-sans-v7-latin-regular.woff2') as="font" type="font/woff2" crossorigin)
body
p Hello World!
img(src=require('image.jpeg'))
const path = require('path');
const PugPlugin = require('pug-plugin');
module.exports = {
output: {
path: path.join(__dirname, 'public/'),
publicPath: '/',
},
entry: {
index: 'src/index.pug', // the `pug-plugin` is required
},
plugins: [
new PugPlugin() // extract HTML from pug defined in webpack entry and save to separate file
],
module: {
rules: [
{
test: /\.pug$/,
loader: PugPlugin.loader, // `@webdiscus/pug-loader` is already included in PugPlugin
options: {
method: 'render', // export the HTML string, rendered at compile time
},
},
{
test: /\.(png|jpg|jpeg)/,
type: 'asset/resource', // <= must be exact this to handles an image
generator: {
filename: 'assets/images/[name].[hash:8][ext]', // save required image under this filename
},
},
{
test: /\.(eot|ttf|woff|woff2)/,
type: 'asset/resource', // <= must be exact this to handles an font
generator: {
filename: 'assets/fonts/[name][ext]', // save required font under this filename
},
},
],
},
}; What is difference by usage The From ver 1.6 I have "improved" the resolving of required resources. The "interpolation" of paths was replaced with "evaluation" of once. Now is possible use a variable in |
Thank you for the investigation. Unfortunately I can't use the assets modules as it's not as flexible when it comes to the output paths. I am trying to make a reproducible small test case, which is not that easy. :) |
I suspect https://github.com/Rush/webdiscus-issue-9-repro I also suspect file-loader has nothing to do with it. It's an issue purely in |
In regards to
|
Just wondering if you were able to run my repo and reproduce? |
Sorry, I am just very busy, I try your repo tomorrow. |
Good luck with whatever keeps you occupied! :)
Thanks! |
yes, I can reproduce the issue and I found the place in the code. I will fix it. |
The problem is by usage variables in template. Temporary solutionAnywhere in PUG use you use already the correct chained properties with - const osName = parsedUA?.os?.name; // RIGHT! In your template this span.browser-icon
+svgIcon(browserIcons[recommendedBrowser]) to span.browser-icon
- const icons = browserIcons?.[recommendedBrowser];
+svgIcon(icons) and in mixin self use properties with mixin svgIcon(iconData, currentColor = 'currentColor')
- const [width, height, _, __, paths] = iconData?.icon || [];
... I understand, this is not comfortable and tricked, sorry, but currently this works with this limitation. P.S. I try to fix it, but it is not easy and not quick. |
The workarounds seem really messy. I will stick with the old version. Probably |
Hello @Rush, in the new version This was a compromise for
But the same limitation has original pug-loader. The problem is with webpack require. My solution in v1.6. was a mega useful "killer-feature", no other pug-loader does this. Do you can please try to test the version 1.7.0? |
Yes thank you. This is now solved. There is another issue for which I'll open a different ticket. |
It only shows the main file where the error is, but it uses a layout which then uses a layout .. the error is hard to find.
The text was updated successfully, but these errors were encountered: