JSPM

outer-script-html-webpack-plugin

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

Inject original js into html, without webpack compiler

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 original js into html, without webpack compiler.

Working with html-webpack-plugin and Webpack 3.

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.js',
          filename: 'js/b.[chunkhash].js'
        }
      ]
    })
  ]
}

ouput html:

  ...
  // original a.js and b.js without compiling will be injected here
  <script type="text/javascript" src="/public/js/a.js">
  <script type="text/javascript" src="/public/js/b.c57c86c1b956c3a01175.js">
  // 'outerScripts' will be injected before other scripts
  <script type="text/javascript" src="/public/others.js">
  ...

License

MIT