stc-inline

Inlining files

Usage no npm install needed!

<script type="module">
  import stcInline from 'https://cdn.skypack.dev/stc-inline';
</script>

README

stc-inline

Inline css/javascript in html.

Use inline attribute in <link rel="stylesheet"> or <script> to trigger this.

<script src="/resource/js/a.js" inline></script>

OR you can set {jsinline: true} to inline other js files. The syntax shoulde be like this:

var xxx = {inline: "/resource/js/a.js"}.inline;

Setting datauri to true or a integer number can inline base64-ified small images in CSS. "Small images" is defined by the value of datauri. If datauri is trusy and isn't a number, the treshold will be automatically set to 32.768kb. According to this.

Setting allowRemote to true can request online js/css files and then bundle them in HTML.

Usage

// stc.config.js
stc.workflow({
  inline: {
    plugin: inline,
    include: /\.(html|js|css)$/,
    options: {
      uglify: true,
      datauri: true,
      jsinline: true,
      allowRemote: true
    }
  },
});

Roadmap

  • HTML JS inline support
  • HTML CSS inline support
  • support uglify
  • use cluster if possilbe
  • support {inline: ""}.inline in js files
  • support picture base64-ify in css files
  • MIME lookup for css datauri inline