1.1.1 • Published 4 years ago

source-inline-webpack-plugin v1.1.1

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

Source Inline Webpack Plugin

This webpack plugin is 3rd party addon to HtmlWebpackPlugin.

Installation

Install the plugin with npm:

$ npm install source-inline-webpack-plugin --save-dev

Install the plugin with yarn:

$ yarn add source-inline-webpack-plugin --dev

Basic Usage

This plugin will inline all script tags that have an inline attribute.

<html>
  <head>
    <script inline src="./example.js"></script>
  </head>
</html>

Will generate:

<html>
  <head>
    <script>
      const example = 'js'
    </script>
  </head>
</html>

Advanced Usage

There is also the inline-prod and inline-staging attributes, which will only inline the asset if NODE_ENV === '[production|staging]' or the env variable INLINE_[PROD|STAGING] is truthy. Otherwise, it removes the script tag from the HTML document. This is useful for analytics scripts that should only be included in production environments.

If not a production environemnt

<html>
  <head>
    <script inline src="./example.js"></script>
    <script inline-staging src="./example-staging.js"></script>
    <script inline-prod src="./example-prod.js"></script>
  </head>
</html>

Will generate:

<html>
  <head>
    <script>
      const example = 'js'
    </script>
  </head>
</html>

If on a staging environment

<html>
  <head>
    <script inline src="./example.js"></script>
    <script inline-staging src="./example-staging.js"></script>
    <script inline-prod src="./example-prod.js"></script>
  </head>
</html>

Will generate:

<html>
  <head>
    <script>
      const example = 'js'
    </script>
    <script>
      const exampleStaging = 'staging'
    </script>
  </head>
</html>

If on a production environment

<html>
  <head>
    <script inline src="./example.js"></script>
    <script inline-staging src="./example-staging.js"></script>
    <script inline-prod src="./example-prod.js"></script>
  </head>
</html>

Will generate:

<html>
  <head>
    <script>
      const example = 'js'
    </script>
    <script>
      const exampleProd = 'prod'
    </script>
  </head>
</html>

Supported Assets Types

  • script <script inline src="./example.js"></script>
  • style <link inline href="./example.css" />
  • img <img inline href="./example.png" />
  • svg <img inline href="./example.svg" />
  • remote assets <link inline href="http://example.com/bootstrap-6.1.css" />
1.1.1

4 years ago

1.1.0

4 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago