@coco-platform/webpack-plugin-inline

inline contents outside webpack compile process.

Usage no npm install needed!

<script type="module">
  import cocoPlatformWebpackPluginInline from 'https://cdn.skypack.dev/@coco-platform/webpack-plugin-inline';
</script>

README

@coco-platform/webpack-plugin-inline

Build Status Coverage Status Package Dependency Package DevDependency

Inline contents outside webpack compile process.

Usage

# npm
npm install @coco-platform/webpack-plugin-inline --only=dev;
# yarn
yarn add @coco-platform/webpack-plugin-inline --dev;

Options

options.files

Optional, files need to inline, relative to process.cwd()

Example

Then config the webpack:

const InlinePlugin = require('@coco-platform/webpack-plugin-inline');
const configuration = {
  plugins: [
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, '__fixture__', 'index.html'),
      inject: 'body',
    }),
    new InlinePlugin({
      files: [
        '__tests__/__fixture__/index.js',
        '__tests__/__fixture__/index.css',
      ],
    }),
  ],
};

Finally output:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Webpack Plugin</title>
  <style>
    html,
    body {
      width: 100%;
      height: 100%;
    }
  </style>
  <script>
    /* eslint-env browser */
    document.addEventListener('load', () => {
    });
  </script>
</head>
<body>
  <script type="text/javascript" src="/main.js"></script>
</body>
</html>

License

MIT