Socket
Socket
Sign inDemoInstall

@a8k/html-loader

Package Overview
Dependencies
749
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @a8k/html-loader

resolve assets in html file


Version published
Maintainers
1
Install size
47.1 MB
Created

Readme

Source

html-inline-assets-loader

自动处理 html 文件中的相对引用 css/js/html 资源 文件,直接内联到 html 文件中,或者自动编译并拷贝到 dist 目录

useage

const configureHtmlLoader = () => {
  return {
    test: /\.(html|njk|nunjucks)$/,
    use: [
      {
        loader: resolve('html-loader'),
      },
      {
        loader: resolve('@a8k/html-loader'),
        options: {
          imageAttrs: [{ name: 'name', value: 'image' }], // 自定义匹配作为图片资源处理的meta
        },
      },
      {
        loader: resolve('nunjucks-html-loader'),
        options: {
          // Other super important. This will be the base
          // directory in which webpack is going to find
          // the layout and any other file index.njk is calling.
          searchPaths: ['./src'],
        },
      },
    ],
  };
};

HTML file

<!--auto transform and copy-->
<link rel="stylesheet" href="./assets/css/reset.css" />
<script href="./assets/rem.js"></script>

<!--inline code-->
<link rel="html" href="./assets/html/meta.html" />
<link rel="stylesheet" href="./assets/css/reset.css?_inline" />
<script href="./assets/rem.js?_inline"></script>

<!-- only process.env.NODE_ENV==='production' -->
<script href="./assets/rem.js?_dist"></script>

FAQs

Last updated on 29 Jun 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc