GitXplorerGitXplorer
e

inert-entry-webpack-plugin

public
7 stars
1 forks
0 issues

Commits

List of commits on branch master.
Verified
500e607ac1266d926a864ac5681261fc3dd198c8

Merge pull request #22 from erikdesjardins/ghact

eerikdesjardins committed 5 years ago
Unverified
9e331fe7ba5430064229f96fcc2c5d4fd5378f72

use github actions, update deps

eerikdesjardins committed 5 years ago
Verified
8b53f9709b72b57b44add67ece161ca4e264c578

Merge pull request #21 from erikdesjardins/fix-webpack450

eerikdesjardins committed 7 years ago
Unverified
44093d595f88cf6221e47d2604c2510532c5fe87

4.0.2

eerikdesjardins committed 7 years ago
Unverified
19d97d78d909aa3e30aa035f3fe3de09d138f37a

pass dependencyTemplates to Module::source()

eerikdesjardins committed 7 years ago
Verified
60a92c045c5d5f9f35dde15514c087580e964709

Merge pull request #20 from erikdesjardins/no-broken-sources

eerikdesjardins committed 7 years ago

README

The README file for this repository.

inert-entry-webpack-plugin

Webpack plugin to allow non-js entry chunks.

Webpack requires that all entry chunks emit valid JS. However, sometimes you want to use HTML or a manifest file as your entry point.

This plugin allows the use of any non-JS ("inert") file in an entry chunk, and prevents Webpack from adding its wrapper to those chunks. This only affects the main compiler, not any child compilers.

Use entry-loader or spawn-loader to emit normal entry points for JS files required in your HTML or manifest files.

Installation

npm install --save-dev inert-entry-webpack-plugin

Usage

webpack.config.js:

var InertEntryPlugin = require('inert-entry-webpack-plugin');

module.exports = {
  entry: {
    nameOfEntryChunk: 'index.html'
  },
  output: {
    path: path.join(__dirname, 'dist'),
    filename: '[name].[hash].html'
  },
  module: {
    rules: [
      { test: /\.html$/, use: ['extract-loader', { loader: 'html-loader', options: { attrs: ['link:href', 'script:src'] } }] },
      { test: /\.css$/, use: ['file-loader', 'extract-loader', 'css-loader'] }
    ]
  },
  plugins: [
    new InertEntryPlugin()
  ]
  // ...
};

index.html:

<html>
<head>
  <link rel="stylesheet" href="./main.css" type="text/css">
  <script src="entry-loader!app.js"></script>
</head>
<body>...</body>
</html>

Output

nameOfEntryChunk.0dcbbaa701328a3c262cfd45869e351f.html:

<html>
<head>
  <link rel="stylesheet" href="e43b20c069c4a01867c31e98cbce33c9.css" type="text/css">
  <script src="main.bundle.js"></script>
</head>
<body>...</body>
</html>

Notice that Webpack's wrapper is not present, as you would expect for an entry chunk.

main.bundle.js will contain the wrapper, however, because it's loaded with entry-loader.