Skip to content

Add html-loader functionality #19

Closed

Description

@m10

It would be really awesome if you could add functionality similar to that of html-loader.

html-loader parses the html and automatically adds assets as dependencies. Something similar should be possible for pug.

TMK this happens on the basis of a list of tags and attributes that should be treated as assets.

Adding this functionality would eliminate the need to use require for assets making the DX even more awesome.
(parcel also does this. HTML as entypoint with automatic asset loading)

Using require for assets could ideally still be optionally possible.

Activity

  1. webdiscus commented on Jun 13, 2022

    @webdiscus
    Owner

    @m10

    Thank for good idea :-)
    We can discuss it.

    1. When we need to define a static assets (vendor scripts, vendor css, vendor images, etc) these already are in public directory, then we can write this public path without require():
    link(href="/static/vendor/css/styles.css" rel="stylesheet" )
    script(src="/static/vendor/lib/socket.io.js")
    img(src="/static/vendor/images/logo.png")
    1. If we want use in Pug the source files, then we can use the require():
    link(href=require('~Styles/main.scss') rel="stylesheet" )
    script(src=require('~Scripts/main.ts'))
    img(src=require('~Images/logo.png'))

    How can we differentiate the path when we should leave it as it is and when we should compile the sources?
    I known, html-loader has a filter option, where we can write a function and self decide, but is very bad practice. Easily is use the require() for source files and not use it for static assets.

    I see only one case for " leave it as is", it is URL like:

    img(src="https://vendor/images/logo.png")
    img(src="http://vendor/images/logo.png")
    img(src="//vendor/images/logo.png")

    But what should be with others?

  2. Repository owner locked and limited conversation to collaborators on Jun 13, 2022
  3. converted this issue into a discussion #20 on Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions