Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Latest commit

 

History

History
43 lines (37 loc) · 1.42 KB

README.md

File metadata and controls

43 lines (37 loc) · 1.42 KB

fork-loader

CircleCI npm version license

Webpack loader to fork input source into multiple down streams.

How to use

      {
        test: /\.html$/,
        rules: [
          // Do not add config here!
          {
            resourceQuery: /fork-tag=foo/, // specified this name by option "marker" of ./loader.js
            oneOf: [
              {
                resourceQuery: /fork-id=a/,
                loader: "noop-loader" // your loaders & configs
              },
              {
                resourceQuery: /fork-id=b/,
                loader: "noop-loader" // your other loaders & configs
              },
            ]
          },
          {
            loader: "fork-loader",
            options: {
              tag: 'foo',
              ids: ["a", "b"]
            },
          }
        ]
      }

In that config, "hoge.html" becomes both "hoge.html?tag=foo&id=a" & "hoge.html?tag=foo&id=b" and we can pass other loaders respectively.
If you want to nest it, see nestedCompiler in "./test/compiler.js".

Maybe this is similar with multi-loader.