occar421 / fork-loader

Webpack loader to fork input source into multiple downstreams

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Webpack loader to fork input source into multiple downstreams

License:MIT License


Languages

Language:JavaScript 100.0%