JSPM

outer-script-html-webpack-plugin

1.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q13893F
  • License MIT

Package Exports

  • outer-script-html-webpack-plugin

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (outer-script-html-webpack-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

outer-script-html-webpack-plugin

Inject js into html without webpack compiler.

Working with html-webpack-plugin.

Install

$ npm install outer-script-html-webpack-plugin --save-dev

Usage

webpack.config.js

const HtmlWebpackPlugin = require('html-webpack-plugin')
const OuterScriptPlugin = require('outer-script-html-webpack-plugin')

module.exports = {
  ...
  output: {
    publicPath: '/public/'
  },
  plugins: [
    ...
    new OuterScriptPlugin(),
    new HtmlWebpackPlugin({
      ...
      outerScripts:[ 
        {
          chunk: '/absolute/path/to/a.js',
          filename: 'js/a.js'
        },
        {
          chunk: '/absolute/path/to/b.[chunkhash].js',
          filename: 'js/b.[chunkhash].js'
        }
      ]
    })
  ]
}

ouput html:

  ...
  <script type="text/javascript" src="/public/js/a.js">
  <script type="text/javascript" src="/public/js/b.c57c86c1b956c3a01175.js">
  // outer scripts will be injected before other scripts
  <script type="text/javascript" src="/public/others.js">
  ...