Code Monkey home page Code Monkey logo

Comments (7)

mjlbach avatar mjlbach commented on June 1, 2024 2

I see. Thanks so much for all of your help!

from pug-loader.

webdiscus avatar webdiscus commented on June 1, 2024

Hello @mjlbach,

Thank You for the reporting of the issue.
I try to reproduce it.

P.S. You could greatly speed up the solution of the problem if you created a small repo with a reproducible issue.

from pug-loader.

webdiscus avatar webdiscus commented on June 1, 2024

@mjlbach

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:

  • Current behaviour
  • Expected behaviour

Clarification

Entry

The key of the entry object is the output filename (without .html extension) relative to output.path.
For details see entry-syntax.

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
},

Output

output: {
    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-loader

Note: the file-loader is deprecated and in Webpack 5 is replaced with asset/resource, see the asset-modules.
Use the asset module asset/resource:

     {
        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]',
        },
      }

from pug-loader.

mjlbach avatar mjlbach commented on June 1, 2024

Thank you so much for the repro and the proactive suggestions on cleaning up our config! It was a hard migration with the webpack upgrades as well haha.

When I use your repo, I can reproduce the problem:

with npm start

Screenshot 2023-02-22 at 7 44 35 AM

Screenshot 2023-02-22 at 7 44 32 AM

with npm run build && cd dist && npx serve
Screenshot 2023-02-22 at 7 45 05 AM
Screenshot 2023-02-22 at 7 45 01 AM

Then apply this patch:

diff --git a/examples/simple-multipage/src/views/home/index.pug b/examples/simple-multipage/src/views/home/index.pug
index c9c34ac..fcc7b21 100644
--- a/examples/simple-multipage/src/views/home/index.pug
+++ b/examples/simple-multipage/src/views/home/index.pug
@@ -9,7 +9,7 @@ html
 body
   h1 Home
   div.nav
-    a(href="about.html") About
+    a(href="about") About
     span &nbsp|&nbsp
-    a(href="contact.html") Contact
+    a(href="contact") Contact
   img(src=require('Images/apple.png') alt="apple")

with npm start

image

image

image

with npm build && cd dist && npx serve

image

image

from pug-loader.

webdiscus avatar webdiscus commented on June 1, 2024

@mjlbach

ah, now I understand your problem.

According to the Web Standards Specification:

  • the URL with end .html is a static HTML file
  • the URL with end / or without .html is a web path (directory), where must be the index.html file

If you need to have a URL as a web path (without .html), then change in the Webpack entry:

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
},

from pug-loader.

mjlbach avatar mjlbach commented on June 1, 2024

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?

from pug-loader.

webdiscus avatar webdiscus commented on June 1, 2024

@mjlbach

It was a "magic" of a web-server (cloudfare has non-standard configuration to allow more flexibility).
Just follow Web Standards to avoid unexpected problems ;-)

from pug-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.