1.0.3 • Published 3 years ago
esbuild-meta-into-html-script-src v1.0.3
esbuild-meta-into-html-script-src
Installation
npm install [-g|--save] esbuild-meta-into-html-script-src
then use on commandline (npx esbuild-meta-into-html-script-src ...
) or in scripts
of package.json
to automate
Usage
esbuild-meta-into-html-script-src metaJsonPath srcHtmlPath desHtmlPath [srcPrefix [desPrefix]]
metaJsonPath
: meta json file path generated by esbuild: https://esbuild.github.io/api/#metafilesrcHtmlPath
: html template file pathdesHtmlPath
: result html path will be written to
srcPrefix
and desPrefix
: prefix to remove in meta json mapping, for example, entering srcPrefix: 'src/', desPrefix: 'dist/'
will make:
'src/web.js': 'dist/web-NPBBEE7I.js'
become:
'web.js': 'web-NPBBEE7I.js'
Example
esbuild-meta-into-html-script-src meta.json src/index.html dist/index.html src/ dist/
Get entryPointMapping from generated html
window.ENTRY_POINTS_MAPPING = typeof window !== 'undefined' ? JSON.parse(
document.head.querySelector('meta[name=entry-points-mapping]')?.content || '{}'
) : {}